How to Use Javascript Promises

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ม.ค. 2025

ความคิดเห็น • 164

  • @yevgeniyaterlyuk3114
    @yevgeniyaterlyuk3114 ปีที่แล้ว +3

    7 years later, this is still the best explanation on promises. Thank you!

    • @DecypherMedia
      @DecypherMedia  ปีที่แล้ว +2

      thanks, that made my day

    • @danial_hamedi
      @danial_hamedi 4 วันที่ผ่านมา

      im from 2025, still the best explanation on promises and we can also consider this an explanation on Monads.

  • @capcadoi
    @capcadoi 8 ปีที่แล้ว +87

    It takes a special kind of intellect to explain a complicated abstract notion properly. You sir are the best I've seen.

  • @harikumar-cq1je
    @harikumar-cq1je 5 ปีที่แล้ว +1

    Waaaav, what an explanation! Only a few people on this planet can explain some things better. This video has finally cleared my question which I am having for a long time. God bless you.

  • @foxtools
    @foxtools 7 ปีที่แล้ว +20

    Watched a bunch of videos and still had no idea what Promises were and how they worked. Watched YOUR video and I GOT IT!!!! You did a spectacular job explaining how it worked and how to use it in different situations. Thank you for you video.

  • @dorjeetsering937
    @dorjeetsering937 8 ปีที่แล้ว +2

    You explained the whole deferred and promise thing in such a simple way. Thank you sir. Though some of the methods used are obsolete now, but is a good stepping stone to understand the new style.

  • @DEVDerr
    @DEVDerr 6 ปีที่แล้ว +3

    Absolutely the best promise explanation I've ever seen so far. Congrats man!

  • @kanishkasinghal5980
    @kanishkasinghal5980 3 ปีที่แล้ว

    The most thorough yet succinct explanation

  • @nikhilverma4976
    @nikhilverma4976 8 ปีที่แล้ว

    Never saw any video explain such concepts so effectively before. Subbed and liked.

  • @officially_leema
    @officially_leema 2 ปีที่แล้ว

    6:07 The way you explained this piece, that the resolve is updating the value property just helped fill another gap in my understanding of promises. I'm still watching but i just wanted to note, because that was a super "Aha moment" for me, thankyou!

  • @mapzitm
    @mapzitm 6 ปีที่แล้ว +1

    This is simply the best tutorial on promises on the whole net! Thank you very much!

  • @Santanaebay
    @Santanaebay 6 ปีที่แล้ว

    Dude this is the best explanation on promises I have ever seen.

  • @WholeNewLevel2018
    @WholeNewLevel2018 7 ปีที่แล้ว +9

    awesome explanation .... most people explain promises in very dry and abstract manner.... what make this tutorial standout is will thought off real world uses of promises and the examples .... this indeed the best video on promises out there ..... thanks so much and please keep up ....

  • @bruceweng3895
    @bruceweng3895 8 ปีที่แล้ว +9

    OMG this is the best promise tutorial I have ever seen!
    Thank you so much~

  • @KaraMedema
    @KaraMedema 4 ปีที่แล้ว

    I was having a hard time wrapping my brain around promises until I watched this video. Thank you for the great explanation!

  • @jacobcoles1
    @jacobcoles1 7 ปีที่แล้ว

    Thank you! Most resources don't explain the structure behind the Promise object as you have done. 11/10.

  • @huibinma1081
    @huibinma1081 4 ปีที่แล้ว

    you have done the best explanation of promise I have seen so far!! Thank you so much!!

  • @barkgj
    @barkgj 8 ปีที่แล้ว

    Impressive how well you explained the concept of JS promises in such an easy-to-understand way, kudos to you!

  • @jamesjovalentine
    @jamesjovalentine 5 ปีที่แล้ว

    I believe that progress bar analogy alone deserves a “like”

  • @zaheeryakub
    @zaheeryakub 7 ปีที่แล้ว

    Jordon, this is the best explanation, someone ever gave me.You are insanely brilliant.

  • @LewizW
    @LewizW 6 ปีที่แล้ว +1

    This is a great explanation. It was nice to see real life examples

  • @andrespineda7620
    @andrespineda7620 7 ปีที่แล้ว

    Thanks! Your video cleared up a lot of things that I was just taking for granted, I now understand how a Promise works at a much deeper level.

  • @imfakeid
    @imfakeid 8 ปีที่แล้ว +5

    by far the best explanation on promises !!!!

  • @spicyricecaker7514
    @spicyricecaker7514 4 ปีที่แล้ว

    By far the best video on promises, thanks a lot!

  • @dajuly20
    @dajuly20 8 ปีที่แล้ว

    wow. Amazing! You made it so clear within seconds. The comparison to a progress bar was the moment when it began to make sence for me :) Thanks!

  • @AmandeepSingh-hd8iq
    @AmandeepSingh-hd8iq 8 ปีที่แล้ว +1

    You are the "Promise" God!! My search ends on this video.:)

  • @matthewsnow6317
    @matthewsnow6317 8 ปีที่แล้ว +1

    Great explanation! It really helped me understand how to use the Q library a lot better.

  • @windday2
    @windday2 7 ปีที่แล้ว

    totally the best explanation so far with the chart you mentioned in the video. Explanation should have those in the future

  • @turbo2ltr
    @turbo2ltr 3 ปีที่แล้ว

    This was very good. I struggle the most with the fact that the code does not run linearly. You can have functions that are defined inline but run at a later time which I find confusing. I much prefer linear code.. I have a question though.. At 18:52, in order to chain a then, don't you have to return a promise from the previous then? The json parse it is returning is not promise or did I miss something?

  • @charliepapa665
    @charliepapa665 6 ปีที่แล้ว

    best explanation I've seen on the topic in youtube

  • @fateriddle14
    @fateriddle14 8 ปีที่แล้ว +2

    Holy shit. Best explanation hands down. Thank you, I finally get it.

  • @michaelchambers236
    @michaelchambers236 6 ปีที่แล้ว

    Wow! Incredibly complex information explained as simply and organized as possible. Thank you !

  • @VishnuPrasadmsvp
    @VishnuPrasadmsvp 8 ปีที่แล้ว

    Awesome, I was so confused with Promises, and this helped me understand it better. Thank you Jordan Leigh

  • @BNingomba
    @BNingomba 7 ปีที่แล้ว

    I am just starting to see the video but run into errors in console, why chrome console is throwing error in my case
    var deferred = Promise.defer()
    VM424:1 Uncaught TypeError: Promise.defer is not a function
    at :1:24

  • @zjevander9739
    @zjevander9739 7 ปีที่แล้ว

    This tutorial is great! Succinct conceptual overview and many practical examples of promises in action. Much appreciated!

  • @natesh1
    @natesh1 6 ปีที่แล้ว

    Best explaination on TH-cam

  • @sukantamangal
    @sukantamangal 7 ปีที่แล้ว

    Thanks for explaining so well that any js beginner can understand this.

  • @devanshdwivedi8893
    @devanshdwivedi8893 6 ปีที่แล้ว

    This is a brilliant video! Absolutely to the point and the all the examples backed up their respective concepts very well. Thank you

  • @rosjio99
    @rosjio99 7 ปีที่แล้ว

    The information may be a bit outdated but the explanation on Promise functions and properties was very helpful! Good job!

  • @acuteclub7381
    @acuteclub7381 7 ปีที่แล้ว

    Finally so;meone who knws how to explain things...... thank you very mutch

  • @imbesrs
    @imbesrs 2 ปีที่แล้ว

    This is easily the best explanation of promises on youtube holy fuck. And trust me when I say i watched them all lol.

  • @badaljain77
    @badaljain77 6 ปีที่แล้ว

    Its really one of the best explanations I have seen so far!

  • @PixelPoosher
    @PixelPoosher 8 ปีที่แล้ว

    Nice! you also taught me some react-native basics on a different video a couple weeks ago. Keep up the good work.

  • @yummo6209
    @yummo6209 6 ปีที่แล้ว +5

    Is this tutorial still valid today (Sept 2018)? I tried to use the first Chrome DevTools(F12) statement
    var deferred = Promise.defer()
    and I got an error ""Promise.defer is not a function"
    I

    • @tomaspyth7017
      @tomaspyth7017 6 ปีที่แล้ว +2

      Obsolete:
      developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Deferred

  • @slidenerd
    @slidenerd 8 ปีที่แล้ว +32

    that was TOTALLY badass mate, if you can explain it , you understand it well enough said Einstein :)

    • @Nicholas108108
      @Nicholas108108 8 ปีที่แล้ว +1

      Which explains why he never gave class or lectures. Or why there are no videos of him talking. Because he was a fraud.

    • @joe44850
      @joe44850 8 ปีที่แล้ว +2

      Yeah. The guy born in 1879 has no videos, so...probably a fraud.

    • @Nicholas108108
      @Nicholas108108 8 ปีที่แล้ว

      Joe Bloggs Because, you know, it's not like the technology was being put to use for decades by the time he was hailed as some sort of incredible genius.
      Actually, people of his time didn't consider him a genius. Did you know that? Wonder why.

    • @joe44850
      @joe44850 8 ปีที่แล้ว +1

      Maybe you meant film, not video, which was invented in 1951. But what do I know, I'm talking to the guy who can discredit Albert Einstein :-)

    • @Nicholas108108
      @Nicholas108108 8 ปีที่แล้ว

      Joe Bloggs lolwut. If you're going to go down that route then WHY won't you mention the fact that a pair of French fellows literally invented everything Einstein wrote down (in his pathetic broken language and math) in that famous first paper?
      What to speak of Hilbert and General Relativity.
      Which leaves this "great man's contribution" where exactly? Well after you give Planck credit for the P-E effect, then you're left with Brownian motion.
      Yeah, give Einstein that one. The phenomenon named after someone else.
      You want to be pedantic about terminology, fine, but the fact is that he is just a jewish poster boy and he was propped up to be that as a form of propaganda.
      GO AND READ HIS ACTUAL PAPERS. THEY ARE BAAAAAD.
      (and don't give me shit like, "hey man, that was turn of the century blah blah". Compare them to Heisenberg, Planck, or even Thompson. Einstein's actual work output is a joke. And the myth around him is unbelievably inaccurate)

  • @thetecheart
    @thetecheart 8 ปีที่แล้ว

    Awesome tutorial on such a complex topic. Huge respect.

  • @slim_mike
    @slim_mike 8 ปีที่แล้ว +1

    this is it! thanks Jordan that was really helpfull! greetings from Venezuela, keep up the good work!

  • @onixz100
    @onixz100 8 ปีที่แล้ว +3

    This is really good. However, is there any reason why we are learning about the whole deferred object thing? Is that just for illustration purposes, or is this video old? From what it looks like (MDN), use of deferred objects with promise.defer() is deprecated.

  • @ameyapatil1139
    @ameyapatil1139 6 ปีที่แล้ว

    Some very very clear explanation out here. Brilliant !

  • @mightyrighty100
    @mightyrighty100 8 ปีที่แล้ว

    Are you using the normal DevTool console from chrome? when i try the same code like:
    var d1 =Promise.defer()
    it says that "VM390:1 Uncaught TypeError: Promise.defer is not a function
    at :1:17"
    what am i doing wrong?

    • @jtreher
      @jtreher 8 ปีที่แล้ว +1

      It's obsolete.

  • @cjcheshire
    @cjcheshire 7 ปีที่แล้ว

    Thanks for making this video. Very clear and thorough examples.

  • @ErnestGWilsonII
    @ErnestGWilsonII 7 ปีที่แล้ว

    Wow excellent video! I watched this in the past but I did not fully grasp the awesomeness! Thank you for taking the time to make this video and share it with all of us! I subscribed!

  • @kaysi768
    @kaysi768 8 ปีที่แล้ว

    honestly one of the best online

  • @iwswordpress
    @iwswordpress 5 ปีที่แล้ว

    Awesome! not seen an explanation like this before.incredibly useful. thanks

  • @srinivasan1482
    @srinivasan1482 8 ปีที่แล้ว

    I got a promise concept in the easy term.Thanks Jordan.

  • @rahuldwivedi4758
    @rahuldwivedi4758 8 ปีที่แล้ว +2

    when I try to actually write deferred in chrome console it says:
    Uncaught ReferenceError: deferred is not defined
    Is it because it's deprecated now?

  • @kerron68
    @kerron68 8 ปีที่แล้ว

    one of the best explanations out there

  • @etisdew2985
    @etisdew2985 7 ปีที่แล้ว

    Hey, could I talk to you? I am new to JS let alone ES6 but I need to store and get JSON information and use the objects for logic and view. I'm a little over my head. Trying not to bloat up with libs and I think this maybe the solution. Everything will be localStorage or hardcoded.

  • @TorbenRudgaard
    @TorbenRudgaard 7 ปีที่แล้ว

    Great video - thanks for explaining the token thingy at the end.

  • @farukabdullamunshi8358
    @farukabdullamunshi8358 5 ปีที่แล้ว

    You explained it greatly Man... Love it

  • @uml01
    @uml01 5 ปีที่แล้ว

    Very good demo and explanation. Thank you.

  • @mclrk
    @mclrk 6 ปีที่แล้ว

    Great video. Does Async/Await replace promises?

  • @weisanpang7173
    @weisanpang7173 6 ปีที่แล้ว

    Hi, after many many hours of watching videos that explained Promises, this is still by far the best video on the topic.
    I only have 1 question that hope anyone can clarify. In any example where one promise .then() method returns another promise and the code just keeps chaining the .then() functions, i assume each .then is acting on different promises objects. If the chain of promises ended with a .catch() function, is this catch function only catching error on the last return promise object, or all promises object in the chain. If it catches all, how does it work that way? What allows the early promises in the chain to see the defined catch function down on a later promise and share that function?
    Thanks for helping.

  • @aaabbb-qv4ff
    @aaabbb-qv4ff 5 ปีที่แล้ว

    This is great, an update video (even with more complicated examples - like async recursion) about defer would be appreciated.

  • @nightlifeking
    @nightlifeking 8 ปีที่แล้ว

    Great tutorial are promises only available in ES5/ES6?

  • @josifyesyes9427
    @josifyesyes9427 6 ปีที่แล้ว

    excellent pretty smart explanation i hope to see Es6 courses from you someday

  • @sergiojimenez3445
    @sergiojimenez3445 7 ปีที่แล้ว

    Do we still need callbacks if know we have promises?

  • @user-sw1wq8lh2w
    @user-sw1wq8lh2w 8 ปีที่แล้ว

    Excellent, I am a big fan of bluebird and hav been using it for a while now, but didn't exactly grasp all of what promises do, now i get it. One question, how would this work together with async/await?

    • @ChrisBen
      @ChrisBen 8 ปีที่แล้ว

      async await always returns a promise ;)
      eg.
      async function doStff () {
      let res = await Promise
      .resolve(1)
      .then(x => x * 3)
      return res;
      }
      doStff().then(x => console.log(x));
      // result 3

  • @jarg7
    @jarg7 6 ปีที่แล้ว +1

    whats the deal with defer promise, is that even used anymore?

  • @dinkersrivastava9429
    @dinkersrivastava9429 7 ปีที่แล้ว

    Super one bro, so cool and nice video with such a nice expiration. Just hats off to you bro... 🙏

  • @cranial3308
    @cranial3308 5 ปีที่แล้ว +1

    Dude, thank you sooo much, such a good explination

  • @VeejayRampay
    @VeejayRampay 7 ปีที่แล้ว

    Wrapping a call to fetch with a function that returns a Promise seems superfluous. It works perfectly fine, but why not call fetch directly from the calling code? As you said, it returns a Promise.

  • @nicolasortiz2638
    @nicolasortiz2638 8 ปีที่แล้ว

    Amazing and wonderful explanation

  • @luisfaria7015
    @luisfaria7015 8 ปีที่แล้ว

    Amazing tutorial. Excellent explanation.

  • @BlueIceAce2015
    @BlueIceAce2015 6 ปีที่แล้ว +1

    Awesome, thanks!

  • @dkennell998
    @dkennell998 7 ปีที่แล้ว

    I finally find someone who can explain promises clearly, and the code is deprecated. :'( Great vid, I would definitely watch an update, though!

  • @AmandeepSingh-hd8iq
    @AmandeepSingh-hd8iq 8 ปีที่แล้ว

    sadly, can't use Promise.defer() now in google chrome. :(

  • @pavellankmiler1833
    @pavellankmiler1833 8 ปีที่แล้ว +1

    Thank you so much !
    Good explanation. Keep doing it :)

  • @MaxwellORoark
    @MaxwellORoark 8 ปีที่แล้ว +1

    This is based off the old api, any plans to update?

  • @airphilosopher
    @airphilosopher 7 ปีที่แล้ว

    Promise.defer is obsolete.. Please update this video...

  • @aikidoshi007
    @aikidoshi007 7 ปีที่แล้ว

    So much info so well presented, well done mate. I can see clearly now ... :-)

  • @sighmanthethird
    @sighmanthethird 8 ปีที่แล้ว

    Really good explanation! Thanks a ton and keep up the good work!

  • @utpalsharma3824
    @utpalsharma3824 7 ปีที่แล้ว +1

    woooww !! that was the best explanation ! thanks a lot .

  • @sathyaprabhagirish3595
    @sathyaprabhagirish3595 8 ปีที่แล้ว

    Amazing video, great practical example!!

  • @andrew5407
    @andrew5407 6 ปีที่แล้ว +1

    Excellent!

  • @bhaktipasaribu
    @bhaktipasaribu 8 ปีที่แล้ว

    Very good explanation! Thanks

  • @Simon-xi8tb
    @Simon-xi8tb 8 ปีที่แล้ว +2

    So promises are still just a pattern for wrapping callbacks in such a way that you can chain them together in more readable fashion.

  • @stopfakingit4846
    @stopfakingit4846 6 ปีที่แล้ว

    Nice one dude. Thanks for sharing I appreciate. You are one of them who can teach ;)

  • @iblockdev7342
    @iblockdev7342 6 ปีที่แล้ว

    Folks, Promise.defer() is deprecated, make sure to switch to new Promise((resolve, reject) => {}) instead

  • @manojverma1052
    @manojverma1052 6 ปีที่แล้ว

    var diferred = Promise.defer()
    VM309:1 Uncaught TypeError: Promise.defer is not a function
    Why so ? I am using chrome console only. I know it is silly but have no clue :(

  • @mikemackes6130
    @mikemackes6130 8 ปีที่แล้ว

    Great job! Really helped me get the concept. Thanks!

  • @judy5367
    @judy5367 6 ปีที่แล้ว

    Pretty good explanation, Thank you very much

  • @jatasya8948
    @jatasya8948 7 ปีที่แล้ว

    Awesome concept explanation, Thank you very much

  • @pepeback
    @pepeback 8 ปีที่แล้ว

    Thanks for your video. Just want to point out than Promise.defer() is obsolete.

  • @starman9000
    @starman9000 8 ปีที่แล้ว

    Jordan, Excellent explanation, Thank you :)

  • @flutterbean
    @flutterbean 8 ปีที่แล้ว

    Dude bro... Nicely done.

  • @rallokkcaz
    @rallokkcaz 7 ปีที่แล้ว

    Why did this style become deprecated?! Ugh, the explanation is so good, and the pseudo code is just right.

  • @Varuag89b
    @Varuag89b 7 ปีที่แล้ว

    great stuff, really helpful. keep up the good work.

  • @MiguelStevens
    @MiguelStevens 8 ปีที่แล้ว

    Great examples! Great video.

  • @chintandd
    @chintandd 8 ปีที่แล้ว

    Nicely explained. Thanks...

  • @RajeshKumar-kl5ci
    @RajeshKumar-kl5ci 7 ปีที่แล้ว

    It' really helpful to understand promise, cheers :)