Promises Basics, Promise.then() & Promise.catch() | JavaScript Tutorial In Hindi #39

  Рет қаралды 223,394

CodeWithHarry

CodeWithHarry

Күн бұрын

Пікірлер: 383
@aniloli
@aniloli 3 жыл бұрын
small try: function checkpwd(pass) { return new Promise((resolve, reject) => { setTimeout(() => { const defaultPass = "admin"; defaultPass == pass ? resolve() : reject(); }, 1000); }); } let passEntered = "harry"; checkpwd(passEntered) .then(() => { console.log("Password matched"); }) .catch(() => { console.log("Access Denied"); });
@ImranKhan-ht2qm
@ImranKhan-ht2qm 2 жыл бұрын
o bhai wah mashAllah. good
@Bhushan_gaikwad10
@Bhushan_gaikwad10 2 жыл бұрын
Bhai function define nhi kiya promise ma
@anantvaid7606
@anantvaid7606 5 жыл бұрын
Bhai, I was trying to learn this from different sites bit was not able to understand. But aapne kya samjhaaya hai🔥. Love you bhai, aapka data science ka bhi playlist mast hai. All the best bhai ❤️.
@vishwasagrawal4700
@vishwasagrawal4700 4 жыл бұрын
Promise.then(console.log('harry bhai explained and fulfiled the promise').catch(console.log('ye kabhi print hi nhi hoga')
@preetiharjani1654
@preetiharjani1654 4 жыл бұрын
i tried oddEven exercise with promise: console.log('tut38(quiz)'); function oddEven() { return new Promise(function (resolve, reject) { setTimeout(function () { let n = 45; if (n % 2 == 0) { console.log('number is even'); resolve(); } else { console.log('number is odd'); reject(); } }, 5000); }) } oddEven().then(function () { console.log("Task resolved"); }).catch(function () { console.log("Oops!!Task rejected"); })
@oook3407
@oook3407 2 жыл бұрын
jan aap nay bht piyara function banaya ha
@avipraidey5767
@avipraidey5767 Жыл бұрын
Very good 😊🙌
@hamidsahi4357
@hamidsahi4357 Жыл бұрын
but we can do same thing by using simple function so whats the difference question
@madhavjaveri1478
@madhavjaveri1478 4 жыл бұрын
var marks=prompt("enter marks"); function papaPromise(){ return new Promise(function(resolve,reject){ score = parseInt(marks); if (score
@prajwalzingare7332
@prajwalzingare7332 2 жыл бұрын
function number(n1, n2) { return new Promise((resolve, reject) => { if (n1 >= 0 || n2 >= 0) { console.log("Function: your promise has been resolved"); resolve(n1 + n2); } else { console.log("Function:your promise has not been resolved"); reject("sorry not fullfilled "); } }); } number(10, -20) .then((result) => { console.log("prajwal:Thanks for resolving " + result); }) .catch((error) => { console.log("prajwal:very bad" + error); }); great explanation thanks harry bhaii❤❤
@muhdani987
@muhdani987 4 жыл бұрын
Behtareen hogaya bhai... harry Bhai aap se Dil lagi hogai he yaar....💞💕❣️💌❤️💝💟💓💗💖 Ab aapke saaray coarses bhi dekhne ka iraada ban Gaya he... Love you 😘😘😘 From Pakistan ❣️
@akankshapatel9508
@akankshapatel9508 2 жыл бұрын
Very useful to understand this during my internship phase thank you!!!!!!
@Blackfeather7777
@Blackfeather7777 2 жыл бұрын
Hi can you help me with what questions you faced during your js interview ?
@the_xibalba
@the_xibalba 4 жыл бұрын
I stumbled upon this video while searching for tutorials on promises, I had been so confused all this time. This worked for me! Thank you Bhai!
@harshchopra1588
@harshchopra1588 3 жыл бұрын
Thanks Harry bhai! Your Quiz solution is here: function dish(){ return new Promise(function(resolve, reject){ setTimeout(() => { const error = false; if(!error) { console.log("Yes!promise is resolved"); resolve(); } else { console.log("No!promise is not resolved"); } }, 4000); }) } dish().then(function(){ console.log("Dish was tasty"); }).catch(function(){ console.log("Dish was insipid"); });
@karanveersingh5535
@karanveersingh5535 3 жыл бұрын
U haven't put reject() then what's the point of putting .catch() function .It won't be called .
@rajputayush6066
@rajputayush6066 3 жыл бұрын
function myFun(num1,num2){ return new Promise(function(resolve,reject){ if((num1+num2) >50){ resolve(); }else{ reject(); } }); } myFun(70,30).then(function(){console.log("Number Is Greater then 50 ")}).catch(function(err){console.log("Number is less then 50")});
@andressergio1532
@andressergio1532 3 жыл бұрын
sorry to be so offtopic but does anyone know of a method to log back into an Instagram account..? I somehow lost my password. I would love any help you can give me
@ikeroliver7186
@ikeroliver7186 3 жыл бұрын
@Andres Sergio instablaster ;)
@andressergio1532
@andressergio1532 3 жыл бұрын
@Iker Oliver I really appreciate your reply. I found the site thru google and im waiting for the hacking stuff atm. Looks like it's gonna take a while so I will reply here later with my results.
@andressergio1532
@andressergio1532 3 жыл бұрын
@Iker Oliver It did the trick and I actually got access to my account again. Im so happy! Thanks so much you saved my ass!
@ikeroliver7186
@ikeroliver7186 3 жыл бұрын
@Andres Sergio you are welcome xD
@bisworajsaheb4171
@bisworajsaheb4171 4 жыл бұрын
Watching right after a year. Wish I had found it before. Thanks Harry bhai.
@karanludhani6072
@karanludhani6072 5 жыл бұрын
Harry bhai dsa k lectures b jaldi upload kijiye... Hm logo k interviews ka time aa gya hai. Or apke lectures se bahot help milti hai.. thank you so much for giving all these contents
@nielltalwar1574
@nielltalwar1574 2 жыл бұрын
thanks harry for such a brilliant and simple explaination. here is my practise let p1=new Promise((resolve,reject)=>{ let input=prompt("enter a number"); if(input%2==0){ console.log("even number"); resolve("Hurray"); } else{ console.log("odd number"); reject("oh no!"); } }); p1.then((msg)=>{console.log(msg); return new Promise((resolve,reject)=>{ let name=prompt("enter your name"); if(name=="nitin"){ resolve(); } else{ reject(); } }) }).then(console.log("Nitin found. balle balle!")).catch((err)=>console.log("Promise rejected!",err));
@codewsohan
@codewsohan 3 жыл бұрын
You resolved your promise. Great explanation ! Loved it ♥️
@amiteshsinghpatel6705
@amiteshsinghpatel6705 2 жыл бұрын
D:sg
@amiteshsinghpatel6705
@amiteshsinghpatel6705 2 жыл бұрын
Pppppp
@gauravsingh4982
@gauravsingh4982 2 жыл бұрын
true
@abhisekupadhaya
@abhisekupadhaya 5 жыл бұрын
Sir, You are best KZbin programmer. Please, Make tutorial on OpenCV for python. I want to apply OpenCV in Machine Learning.
@Satish_Kumar_Gupta
@Satish_Kumar_Gupta 4 жыл бұрын
harry bhai aapne apna best promise video ko successfully resolve kar liya. Thank you so much...:)
@AkshitSangwan-v8l
@AkshitSangwan-v8l Жыл бұрын
Best Expalanation ever in the most layman language.
@maaz1150
@maaz1150 4 жыл бұрын
Learning my entire engineering from here. Thank you.
@Shillu1988
@Shillu1988 5 жыл бұрын
Finally Today I have understand Promises, Thanks Bro
@av1shek_ps
@av1shek_ps 5 жыл бұрын
Can any one explain me or give me code how to use setTimeout in promise? Is it necessary to define function in promise only can we not give only name of function there and define it at any other place.
@av1shek_ps
@av1shek_ps 5 жыл бұрын
Bro if you know can you explain me
@av1shek_ps
@av1shek_ps 5 жыл бұрын
//Can anyone tell me how to wrap it with setTimeout function console.log('Now you are online.'); function callingfun() { return new Promise(function (resolve, reject) { let xhr = new XMLHttpRequest(); xhr.open('GET', 'kk1.txt', true); xhr.onload = function () { if (this.status === 200) { console.log(this.responseText); resolve(); } else { console.log('some error occured'); reject(); } } xhr.send(); }) } callingfun().then(function () { console.log('promise resolved'); }).catch(function () { console.log('promise rejected') });
@Virus-ke8xj
@Virus-ke8xj 4 жыл бұрын
@@av1shek_ps I think there's no point in using setTimeout function over here, I mean, what you are doing is sending a get request and checking the status of the response, there's not time involved right? If u want you can add it, but here it seems to be illogical
@Virus-ke8xj
@Virus-ke8xj 4 жыл бұрын
Just wrap everything starting from initialisation of XML object to the end inside the setTimeout function
@sohamnesarikar5516
@sohamnesarikar5516 4 жыл бұрын
Harry bhai...apne promise pura kiya...samaj aa gaya promise😄❤️
@anantraj1071
@anantraj1071 4 жыл бұрын
harry bhai ...bht jagh se try kra kia but atlast yha jake samjh aaya thnxxx bhaii!!!!!
@sourabhsivare1876
@sourabhsivare1876 2 жыл бұрын
Bro great explaining, hats off to your efforts
@muneebzubair5069
@muneebzubair5069 4 жыл бұрын
promise resolved() with Love from Pakistan Lahore Punjab ❤️
@dr.ramkishorsah495
@dr.ramkishorsah495 4 жыл бұрын
waah kya explanation so easy to understand to learn a complex thing. Salute🤘🙏🙏🙏
@abhimalvekr127
@abhimalvekr127 4 жыл бұрын
Good one bro. Bohot ache se samjhaya bhai ne! Keep up the good work
@kartikeykakaria8a168
@kartikeykakaria8a168 3 жыл бұрын
Sir maine kahi jyada jagahon se promises sikhne ki koshish ki par samajh nahi aaya par aapki video dekhke pehli bar mein hi samajh aa gya. You the best programmer on youtube! One request : pls make a tutorial on sql also please :)
@aevanvaghani3593
@aevanvaghani3593 Жыл бұрын
okkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkl.
@umergillani5046
@umergillani5046 4 жыл бұрын
Love from Pakistan Karachi❤️
@muhammadyousufjaseem4084
@muhammadyousufjaseem4084 3 жыл бұрын
I'm also
@shaneqasim5137
@shaneqasim5137 3 жыл бұрын
@@muhammadyousufjaseem4084 Same
@shreenidhideshpande
@shreenidhideshpande 4 жыл бұрын
I think I searched all sites, books but not got the concepts this much clear . Thank you very much Bhai. please make a series on react and node too
@paramsaini6932
@paramsaini6932 2 жыл бұрын
Best In The World (ABOVE ALL) THANKS bro
@rpnrko3612
@rpnrko3612 2 жыл бұрын
Understood in one go. Patte se headshot Harry bhai!!!
@travelnlearn
@travelnlearn 2 жыл бұрын
mast hai bhai maja aa gaya
@savanpatel9641
@savanpatel9641 4 жыл бұрын
thank you bhai ...........u r d best youtube programmer ever................
@parmarmayank7087
@parmarmayank7087 4 жыл бұрын
You are amazing brother. God bless you
@hassanahmed8216
@hassanahmed8216 2 жыл бұрын
Amazing explanation!!!❤️❤️❤️
@utkarshsingh2912
@utkarshsingh2912 2 жыл бұрын
console.log('Promise Quiz') function promise(){ return new Promise(function(resolve, reject){ let understood = true; if(understood){ resolve(); } else{ reject(); } }); } promise().then(()=>{ console.log('Thankyou harry bhai sab samjh me aagya'); }).catch(()=>{ console.log('Samjh ni aya') })
@pratikpawar376
@pratikpawar376 3 жыл бұрын
//Harry bhi ka promise function pratikpromise(){ return new Promise(function(resolve, reject){ setTimeout(()=>{ let error = false; if(!error){ console.log("Harry bhai ka video dekha samaj me aa chuka hai as per the promise of harry bhai"); resolve(); } else{ console.log("Harry bhai ka video phir se dekh le samaj aa jayega"); reject(); } }, 1000) }); } pratikpromise().then( function() { console.log("Thank you So much Harry Bhai"); }).catch(function() { console.log("Sorry Harry bhai, lekin koshis karuga samaj ne ki") });
@javeriyakhan1773
@javeriyakhan1773 2 жыл бұрын
promise resolved!! well explained!!👍
@TechnicalAnkesh
@TechnicalAnkesh 3 жыл бұрын
Harry bro as always you resolved your promise LOVED YOUR EXPLANATION🤩🥰
@vieharchives8208
@vieharchives8208 2 жыл бұрын
// If you know Python, this concept is similar to Try and Except. // Here is simple example of Promises function oddEven(number) { return new Promise(function (resolve, reject) { if (number%2==0) { resolve(); } else { reject(); } }) } oddEven(16).then(function () { console.log("Your number is Even") }).catch(function () { console.log("Your Number is Odd"); })
@anubhavverma1591
@anubhavverma1591 2 жыл бұрын
Promise Resolved Thanks Harry ❤
@sports4yoo
@sports4yoo 2 жыл бұрын
3M Soon Harry Bhai big congratulations in advance 🎉❤
@vikaschauhan-rv6fi
@vikaschauhan-rv6fi 3 жыл бұрын
starting mai laga tha ki nahi aayega samajh mai, par 1 dum badiya se samajh aagaya
@karthikjoshi6386
@karthikjoshi6386 4 жыл бұрын
Famous club concept if (age
@afsanatasnim3542
@afsanatasnim3542 2 жыл бұрын
ur comment helped me to know the difference
@afsanatasnim3542
@afsanatasnim3542 2 жыл бұрын
thnks
@ibtehaj95
@ibtehaj95 2 жыл бұрын
Thanks a lot bro. You explained it very well.
@harshpreetsingh6971
@harshpreetsingh6971 2 жыл бұрын
Thanks for resolving your promise ♥️🙏💯
@Saifolic
@Saifolic 5 жыл бұрын
it's really very useful thanks a lot
@ajinkyajadhav8049
@ajinkyajadhav8049 3 жыл бұрын
function sum(a,b){ return new Promise (function(resolve, reject){ let c = a+b; if (c >100){ console.log("Sum of A and B is : ",c) resolve("sum is greater than 100") } else{ console.log("Sum of A and B is : ",c) reject("sum is less than 100") } }) } sum(10,23).then(function(a){ console.log(a); }).catch(function(b){ console.log(b) })
@bantisharma8119
@bantisharma8119 4 жыл бұрын
Best Video for learning Javascript. Thank you harry bhai
@vivekkumar-pc1xy
@vivekkumar-pc1xy 2 жыл бұрын
mein just abhi brad traversy ka lecture attend kiya tha udemy se, Promises ka. Difference itna hai apne us lecture ko hindi mein explain kr diya. But mughe ab smgh agya
@osamakhan2552
@osamakhan2552 3 жыл бұрын
I have watch this video 4 time now finally i'm understand 😍
@Unrealinsaan72
@Unrealinsaan72 4 жыл бұрын
The way you are explaining is really good.
@khelanmehta1554
@khelanmehta1554 3 жыл бұрын
Awesomeeeee bro dhang se samhjha diya tune
@mrinalraj7166
@mrinalraj7166 2 жыл бұрын
Thank you harry bhai. You are god.
@webprogramminghindiurdu3279
@webprogramminghindiurdu3279 4 жыл бұрын
Bohut acha explain kiya bhai ap ney
@Travelmoments
@Travelmoments 4 жыл бұрын
Sabashhhh!!!!! bhahut badiya samjaya apne..
@shrutigoyal3494
@shrutigoyal3494 4 жыл бұрын
you nailed it. and yes it is a resolve.
@TheCuratedUX
@TheCuratedUX 2 жыл бұрын
great content
@thevarunparashar
@thevarunparashar 4 жыл бұрын
You are an amazing guy... keep it up
@Rahulyadav-ry1lk
@Rahulyadav-ry1lk 5 жыл бұрын
Sir ke fan like thoko👈👌🤙
@Rahulyadav-ry1lk
@Rahulyadav-ry1lk 5 жыл бұрын
Big fan
@vipinsaini3497
@vipinsaini3497 4 жыл бұрын
Hi. Your tutorial is informative. I loved it. Thanks for sharing and keep the good work going
@javascriptwar9525
@javascriptwar9525 4 жыл бұрын
you save my life brother..🙌awesome
@ayushajayuzfmvwfenu7720
@ayushajayuzfmvwfenu7720 3 жыл бұрын
after buying the Coding ninja web dev course, come here to catch on, easy to understand video loved it ❤️
@webcreationstudio7088
@webcreationstudio7088 3 жыл бұрын
apne course liya tha kiya?
@ayushajayuzfmvwfenu7720
@ayushajayuzfmvwfenu7720 3 жыл бұрын
@@webcreationstudio7088 yes
@VedPrakash-kf6kv
@VedPrakash-kf6kv 3 жыл бұрын
congratulation for 2million hary bhai
@insaanonline
@insaanonline 3 жыл бұрын
thanks
@yashwantsahu1752
@yashwantsahu1752 4 жыл бұрын
promise done perfect harry bhai ...
@anaskhan4841
@anaskhan4841 3 жыл бұрын
Much Much Appreciated Harry Bhai...
@sugandhaparasher8861
@sugandhaparasher8861 3 жыл бұрын
Super Dost... very well explained
@vaibhavkulkarni5601
@vaibhavkulkarni5601 4 жыл бұрын
Very nicely explained Harry bhai !!
@parshantmadaan4709
@parshantmadaan4709 Жыл бұрын
Your promise resolved Thanks
@deepakguled809
@deepakguled809 Жыл бұрын
I initially watches your promises on ultimate javascript course very confusing there here clearring explained my suggestion kindly upload this in that playlist
@pushkarkumar5578
@pushkarkumar5578 4 жыл бұрын
bhai gajab padhate hoo app maja agaya :*
@MuhammadBilal-fw7gh
@MuhammadBilal-fw7gh 3 жыл бұрын
Harry bhai you really resolved your promise❤😉
@shivamnayak2998
@shivamnayak2998 2 жыл бұрын
function compare(a,b){ return new Promise(function(resolve,reject){ if(a===b) resolve("Equal"); else reject("Not equal"); }) }; const genericFn = (str) => console.log(str); compare(3,4).then(genericFn).catch(genericFn);
@hmmmza
@hmmmza 2 жыл бұрын
function isDay(hours){ return new Promise(yes, no){ if(hours>5 && hours
@hitenarya4987
@hitenarya4987 5 жыл бұрын
Harrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry bhai awesome video :D
@Hassanali-tj1kq
@Hassanali-tj1kq 2 жыл бұрын
bhi muzy tu maza a agya phr na ma mara pura samj ma a gaya thank you bhi
@moderngypsy5980
@moderngypsy5980 2 жыл бұрын
How should I thank you Harry bhai, you are the best..
@nayankumarshit7522
@nayankumarshit7522 5 жыл бұрын
Harry bhai i like your django tutorials.. love you vai
@iamSadabAlvi
@iamSadabAlvi 5 жыл бұрын
I am always ready for your video Like too banta hai
@akashsolanki5570
@akashsolanki5570 3 жыл бұрын
@codewithharry please explain the Promise constructor. Isn't it supposed to make a object, which should look like this {...} when we do console.log(func1())
@ibtehaj95
@ibtehaj95 2 жыл бұрын
Yes, Promise will create a new object. Harry just chained more stuff to it and probably displayed it (I don't remember the timestamp). I wrote very simple code to make myself understand, it might help. ///////My Code//////////// let oath_keeper = 0; const promiss = new Promise(function(accept, excuse){ if(oath_keeper === 1){ accept("Oath Kept"); } else{ excuse("Oath Broken"); } }); promiss.then(function(message){ console.log(`Message from Promiser: ${message}`); }).catch(function(message){ console.log(`Message from Promiser: ${message}`);; });
@lopamudrasahu2202
@lopamudrasahu2202 2 жыл бұрын
superb brother
@ashpreetsinghanand7260
@ashpreetsinghanand7260 2 жыл бұрын
function f2(){ return new Promise((resolve,reject)=> { setTimeout(() =>{ let flag=true; if(flag==true){resolve();} else{reject();} }, 2000}; }); } f2.then(()=>{console.log("no error from API");}).catch(()=>{console.log("error");})
@msbasera
@msbasera 2 жыл бұрын
Thank you bhai ❤️
@pranaykosulkar641
@pranaykosulkar641 4 жыл бұрын
Harry Bhai you resolved your promise 🙏 ❤️👍
@subhasishsahu9749
@subhasishsahu9749 3 жыл бұрын
thanks bro i was so confused about this and you helped me a lot .
@khatariinsaan5284
@khatariinsaan5284 2 жыл бұрын
Mai aap logo se promise karta hu ke mai aap logo to *promise* acche tarike se batunga What a way to teach 😂😍
@sushmapatil4478
@sushmapatil4478 2 жыл бұрын
Wow very nice
@shaheensiddiqui1952
@shaheensiddiqui1952 3 жыл бұрын
sir we are always see you full vidio
@aasrivastava5851
@aasrivastava5851 5 жыл бұрын
Your videos are very good sir.Appreciate your youtube work. Please make a video on AJAX
@CodeWithHarry
@CodeWithHarry 5 жыл бұрын
I have already uploaded a video no Ajax with title "Ajax tutorial in hindi" Kindly access the playlist!
@AbhaySingh-dd9xc
@AbhaySingh-dd9xc 4 жыл бұрын
@@CodeWithHarry harry bahii bilkul right
@abhijitbarman4401
@abhijitbarman4401 4 жыл бұрын
Harry bhai apne promise pura kardia!
@Ertyuiigff-sq5fi
@Ertyuiigff-sq5fi 3 жыл бұрын
superb video
@divyanshuverma3205
@divyanshuverma3205 2 жыл бұрын
Hillarious sometimes - " mai aapse promise krta hu ki aapko ...Promise() ... achhe se btaunga yahi hota hai promise" 😂🤣😂🤣😂
@tanmoyhaldar4514
@tanmoyhaldar4514 3 жыл бұрын
I think my iitkkgp profs will also not teach me like this. Loved the way you used examples.
@prit7787
@prit7787 3 жыл бұрын
THANKS HARRY!!
@muhammadjunaid2329
@muhammadjunaid2329 3 жыл бұрын
Love from Pakistan Bhakkar🧡
@fattehalisunasarasunasara4111
@fattehalisunasarasunasara4111 5 жыл бұрын
Sir materialize css ki series banavo please
@networkguy6650
@networkguy6650 4 жыл бұрын
Thanks buddy..... btw liked+subscribed
@biswamohandwari6460
@biswamohandwari6460 4 жыл бұрын
Tussi great ho
@laxmipriyapradhan1704
@laxmipriyapradhan1704 2 жыл бұрын
Please harry kya ap ye 4 concept ko milake ek website banana sikha sakte ho please please please🙏 - Generator - Promises - AJAX Request - - Callback Function
@girishpandey9976
@girishpandey9976 2 жыл бұрын
Nice tutorials
Project 3: Creating a News Website | JavaScript Tutorial In Hindi #40
42:02
Async/Await in JavaScript | JavaScript Tutorial in Hindi #59
20:08
CodeWithHarry
Рет қаралды 304 М.
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 61 МЛН
Async/Await in Javascript | JavaScript Tutorial In Hindi #43
13:50
CodeWithHarry
Рет қаралды 232 М.
Promise in javascript | chai aur #javascript
50:21
Chai aur Code
Рет қаралды 312 М.
Introduction to Promises | JavaScript Tutorial in Hindi #54
13:27
CodeWithHarry
Рет қаралды 327 М.
Callback functions in javascript | JavaScript Tutorial In Hindi #37
17:49
Master The Promises in JavaScript in Hindi in 2022
29:12
Thapa Technical
Рет қаралды 138 М.
Asynchronous JavaScript Course (Async/Await, Promises, Callbacks)
1:36:23
freeCodeCamp.org
Рет қаралды 694 М.
What are JavaScript PROMISES? 🤞
12:37
Bro Code
Рет қаралды 82 М.
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН