JavaScript Promises -- Tutorial for Beginners

Sdílet
Vložit
  • čas přidán 16. 06. 2024
  • JavaScript Promises and all their glory! This is episode 12 in a 10 part series I’m calling 10 things Javascript Developers Should Know But Probably Don't.
    JavaScript Promises
    Different phases of a Promise
    Chaining Promises
    Handling errors using Promises
    Benefits over callbacks and callback hell
    What do they all mean and why do you need them?
    Full playlist here: • 20 Things JavaScript D...
    JavaScript Promises from the series "10 Things JS Developers Should Know"
    by ColorCode.io, Sina Jazayeri
    ** Announcement **
    Full JavaScript Mastery course is coming! Details at the end of the video. Sign up for Early Access here:
    www.colorcode.io/js-mastery
    0:00:00 Intro
    0:01:48 Async vs. Sync
    0:03:29 The problem with Async
    0:07:00 Convert to Callback
    0:08:00 Convert to Promises
    0:10:32 Different phases of a Promise
    0:11:47 How to use a Promise
    0:14:47 Why do we like Promises?
    0:16:30 Chaining
    0:20:59 Benefits of Promises over Callbacks
    0:22:50 Error handling, REJECT and .catch()
    0:30:23 .finally()
    0:31:50 Real world example with fetch()
    0:34:30 Summary
    0:35:13 Next...

Komentáře • 439

  • @ColorCodeio
    @ColorCodeio  Před rokem +44

    🎉👨🏻‍💻 JavaScript Promises and all their glory! This is episode 12 of a 10 part series I’m calling 10 things Javascript Developers Should Know But Probably Don't. Enjoy!

  • @amanueletana
    @amanueletana Před rokem +24

    This is not only coding tutorial rather its an ART!

  • @Saliha_Abid
    @Saliha_Abid Před rokem +15

    I am a 15 year old learning front-end development and struggling with promises. After 3 days of exhaustion I found ur video and finally got the whole concept. Thank you for this masterpiece 😍😍

  • @user-gi3oc1kv5m
    @user-gi3oc1kv5m Před rokem +72

    I’ve been watching videos for years trying to make sense of Promises, and while I got through it, I’ve always wanted to come back and really understand them. Your video turned the light bulb on for me. Wow! I had to tip you for the help!
    I appreciate it so much! Definitely subscribing!

    • @ColorCodeio
      @ColorCodeio  Před rokem +6

      That’s so great to hear. Thanks for sharing.

    • @deveren
      @deveren Před 4 měsíci

      @@doublewhopper67 ure da g

  • @AJD...
    @AJD... Před rokem +51

    Been watching your shorts for a while, decided to hop into your channel and this is the first video I watched. Holy hell the quality of your videos is mind blowing. You put so much effort into edits and your explanation is very planned, with a set preordained path which makes the most sense.
    You've got a new sub.

  • @user-eq9gs7bl2e
    @user-eq9gs7bl2e Před rokem +19

    i can tell you put a lot of passion and effort into your work bro its inspiring

  • @stephenkettley
    @stephenkettley Před 4 měsíci

    Man your content is so insightful and relaxed at the same time! Loving it.

  • @xClown55
    @xClown55 Před rokem +3

    There aren't many video's that are 30+ minutes worth rewatching, but this one certainly is. Nice video

  • @guy_roh
    @guy_roh Před rokem +6

    Thank you so much for making an actually apprehensive video that normal people can understand, explaining the why's and how's in a much better detail than a lot of other videos I've watched! Subscribed and added this to my favorites in case I should I need it in the future! 👍

  • @lemonbubble1243
    @lemonbubble1243 Před 7 měsíci +16

    3 days ago I wanted to watch just this video but the title made me look for the whole series, and I knew that to understand better I needed to watch the previous episodes, and OMG I'M GLAD I DID. I feel I have like a super knowledge now, EVERYTHING MAKES SENSE NOW!! I don't know how to express how grateful I am!! I'm so excited because you cleared all my doubts about promises and not just promises, now I understand Objects() way better! THANKS!! Waiting for your master class!!

  • @AriKhuu
    @AriKhuu Před rokem +9

    I'm so happy to be finding your channel I want to cry. Impeccable production. Clear examples. Perfect pacing - not too fast, not too sluggish. Detailed yet very follow-able explanation. Funny host. thank you thank you thank you.

  • @BitWizCoder
    @BitWizCoder Před 9 měsíci

    This is the first time I'm seeing this guy, 30 seconds into the video, and I had to subscribe. Thanks for the video and the fun!

  • @carsten1223
    @carsten1223 Před 9 měsíci

    I just came across your channel. You have a really great way of explaining things and giving them some context. Thumbs up 👍and I'm looking forward to hopefully many more videos like this!

  • @erickchavez4551
    @erickchavez4551 Před 11 měsíci +4

    I really like how your examples lead to real life situations and at the end it doesn't seem that complicated. Thanks!

  • @johnnya246
    @johnnya246 Před rokem +4

    A very underrated channel. I like your style of teaching! Thank you for the content! Keep up the good work!

  • @toohee8561
    @toohee8561 Před rokem

    This will be the one video that gets me understand the basics concepts of promises. very good video outline and content.

  • @chaoticthundergod3368
    @chaoticthundergod3368 Před 9 měsíci +1

    Thank you for this video. Leaned a lot. I was learning about promises a year ago, didn't understand much so skimmed through it. But now i can explain to others what a promise is.

  • @rjerez
    @rjerez Před rokem +6

    Great work Sina, this is a subject that a lot of people seem to get wrong on interviews. Now I can refer them to this video. 👍🏽

    • @ColorCodeio
      @ColorCodeio  Před rokem

      Thank you Ronald for your support, always!

  • @mashmixture5662
    @mashmixture5662 Před rokem +3

    Learn alot from ColorCode in just one month.
    Such an amazing content.
    The way you explain things is very very very interesting and funny.
    *Best JS channel* on CZcams.
    Thanks for such a premium content.
    Please deliver more.

  • @proudmoroccan8164
    @proudmoroccan8164 Před 5 měsíci +1

    Thank you for sharing. Immensely appreciated. The best JavaScript promise tutorial as far as I am concerned. Best wishes for the new year.

  • @vighneshs416
    @vighneshs416 Před 7 měsíci +3

    I stumbled upon your channel from a random CZcams shorts. I am very certain that soon you are going to be a lot of people's go-to channel for Javascript (Or anything that you make content on). The effort you put in to make the concepts intuitive is just top-notch. And I guess it is very evident from the other comments as well. Thanks for the effort you are putting in man

    • @blaqhakym
      @blaqhakym Před 7 měsíci +1

      Exactly the same for me. Looks like I will be here for a while. I'm hitting sub right away

    • @ColorCodeio
      @ColorCodeio  Před 7 měsíci +2

      Thank you both! Welcome aboard.

  • @ahmedAltariqi
    @ahmedAltariqi Před rokem +1

    That was pretty well explained, and FUN to watch ! Thank you, Weather Man!

  • @user-hs6jw1wm7i
    @user-hs6jw1wm7i Před rokem +1

    Lot's of gratitude from me here Js Master, this series is really impacting me...

  • @strangelight159
    @strangelight159 Před rokem +1

    5 minutes into the video and I can already tell that you are criminally underrated. Subbed

  • @ferreven2558
    @ferreven2558 Před rokem +1

    Thank you so much for this video! Finally someone who can explain promises well.

  • @sergeysviridenko9603
    @sergeysviridenko9603 Před 11 měsíci +1

    you're the best of 7 videos about promises I've seen

  • @bakenbard
    @bakenbard Před 4 měsíci

    That was really helpful, I'm finally got the basics of it. THANK YOU!

  • @sourikray2291
    @sourikray2291 Před rokem +3

    You are a wonderful teacher. Thank you for creating these videos🙏

  • @mohamedabdulmueen2115
    @mohamedabdulmueen2115 Před rokem +1

    I loved everything in this video man, keep it up !

  • @theshtig4218
    @theshtig4218 Před 11 měsíci +1

    GOATED video. This will be the last promise video I ever watch. Thank you!

  • @jeffersonr.l2864
    @jeffersonr.l2864 Před rokem +1

    This content is simply amazing! Thanks for your effort in creating quality content, I learn a lot thanks to it.

  • @nitishgupta9585
    @nitishgupta9585 Před rokem +1

    Bro your explanation of concepts is top notch. Keep the good work up!!

  • @mansoormohmand5852
    @mansoormohmand5852 Před rokem +1

    I have seen lots of videos and tutorials but never use this topic of promises in my coding because of the bad and hard explanation, but now I am pretty sure I can use and refer to this great explanation ever, thanks a lot

  • @aleksazlatkovic4663
    @aleksazlatkovic4663 Před rokem +1

    What a charismatic person you are. Good Lord.
    I started the video knowing nothing about Promises and I am finishing it as an absolute pro.
    Thank you for going into detail.

  • @breemudi
    @breemudi Před 11 měsíci +1

    My first time ever watching you, and I'm intrigued by your tutoring style.
    Instant subscriber... Thank you

  • @raheem81kg
    @raheem81kg Před rokem +1

    Top quality as always

  • @2difficult2do
    @2difficult2do Před rokem

    Thus is the best explanation of Promise! Thank you so much!

  • @chetanchaudhary1017
    @chetanchaudhary1017 Před 19 dny

    Best video on Promise I have ever watched.

  • @bendustin7609
    @bendustin7609 Před 2 měsíci

    Thank you for putting out such high quality videos!

  • @skyfall5288
    @skyfall5288 Před měsícem

    ممنونم بابت توضیحات عالیتون.
    واقعاً به این ویدئو نیاز داشتم... :)) ❤

  • @msunrl8577
    @msunrl8577 Před rokem +1

    24:28 u so right about repeating and coding from scratch again and again, this so important to memorize and practice some hands on
    great tutorial, thanks

  • @krypton_dev
    @krypton_dev Před 4 měsíci

    another GREAT video. Thanks a lot SINA

  • @rohanagrawal5747
    @rohanagrawal5747 Před rokem +1

    yeeeee i was waiting for this video

  • @nikolanovakovic4150
    @nikolanovakovic4150 Před 7 měsíci +2

    Brooooooooooooo 🎆🎇❤🧡💛💚💙💜 first of alll, love your humor, second of all amazing content struturing it is so well organized an succinct and i will do what all the other people in the comment section did compliment how good your videos are. much love !

  • @rishayshandilya1817
    @rishayshandilya1817 Před 10 měsíci +1

    the best explanation of promises I promise :)

  • @eumm11
    @eumm11 Před rokem +1

    always great, you never disappoint!

  • @jw200
    @jw200 Před 10 měsíci +2

    No Promises that I learned to Promise.
    Excellent tuts and explanations. Liked and subbed! Love your energy🙂

  • @abahiduh3246
    @abahiduh3246 Před rokem +2

    I have watched the best vidoes of Kyle Simpson, Tyler McGinnis, Tony Alicea, colt Steele, Jim cooper, Aksay, Ania, Maximilian, Sasha, I can go on and on.... I spent A LOT of Money just to understand. I have watched ALL YOUR VIDEOS.
    I can assure you that this explanation got.YOUR EXPLANATION of SIMPLIFYING THE CODE before refactoring in simply the Best.
    Your tutorial is AMONGST THE BEST THREE for me. THANK YOU, THANK YOU, THANK YOU.

    • @ColorCodeio
      @ColorCodeio  Před rokem

      Thank you so much. This is very encouraging to hear.

  • @onais__
    @onais__ Před rokem

    UUFFFFF The Chaining explanation was 🔥🔥🔥

  • @sh9vch9nk0
    @sh9vch9nk0 Před 4 měsíci

    Great video, clear and detailed!) Thank you a lot 😊🙏

  • @akasharthanur3057
    @akasharthanur3057 Před rokem

    You are just awesome, keep up your work... Learnt a lot!! Thanks for this... I love JavaScript!!

  • @ashaymotiwala96
    @ashaymotiwala96 Před rokem +1

    Best Javascript tutorials on YT!

  • @sarkorbekabdullaev9581
    @sarkorbekabdullaev9581 Před rokem +1

    Thank you bro, can't wait for Episode 13 Async/Await

  • @jasonblewis
    @jasonblewis Před měsícem +1

    Excellent tutorial, thank you

  • @Epikht
    @Epikht Před rokem +2

    i'm gonna comment fort the third time, that is the best video about Promise all over this app
    I spend 2 days on it, messing around with my own things
    Thanks a lot Color Code

  • @CW-pd5fq
    @CW-pd5fq Před 5 dny +1

    Your teaching style is amazing, please continue your work 🙂

  • @godnonamesleft
    @godnonamesleft Před rokem +1

    This is so well made. Thank you.

  • @mrayaan8377
    @mrayaan8377 Před měsícem +1

    You nailed it man.. best explanation on whole youtube. i was frustrated. but now i know the whole concept of promises. SUBSCRIBED🌞❤

  • @blu3tan
    @blu3tan Před 4 měsíci

    nice setup, nice host, nice code, nice music, nice edit, nice english

  • @richardradcliffe6178
    @richardradcliffe6178 Před rokem +1

    Thank you. Looking forward to your video on async awaits!

  • @alanouri9965
    @alanouri9965 Před rokem +1

    Very smooth,keep up the good work bro

  • @mikeyim9597
    @mikeyim9597 Před rokem +2

    Glad I found your channel. It's the best explanation of the Promise and Async Await. Can you please do a series on the same topic for database CRUD? Thank you.

    • @ColorCodeio
      @ColorCodeio  Před rokem +1

      I'm considering doing one on CRUD operations with Firebase.

  • @16NaruSasuke
    @16NaruSasuke Před rokem +1

    Thank you very much. Your videos are awesome, it is very clear what you are saying.

  • @sars8374
    @sars8374 Před rokem

    Amazing explanation! I have been enjoying your series quite a lot. Looking forward to other videos. Btw, there is a small error in the video, fetch by default returns a Promise, we don't need to create it ourselves :)
    Have a nice day/night!

  • @gaganbaghel1377
    @gaganbaghel1377 Před rokem

    THE BEST JS CHANNEL

  • @user-kn4oi9oh4i
    @user-kn4oi9oh4i Před 3 měsíci +1

    Thank you so much for this!! ❤❤❤❤

  • @web3withbeny
    @web3withbeny Před 3 měsíci +1

    Like the way that you teach, wonderful!

  • @RoockYou
    @RoockYou Před 9 měsíci +1

    Your explanation is so funny and so helpful at the same time, Hope you keep doing videos this way

  • @nucleareggdevar
    @nucleareggdevar Před rokem +1

    Phenomenal. Beyond phenomenal.

  • @khalidsaifullahfuad
    @khalidsaifullahfuad Před rokem +1

    Loved the intro 🔥.

  • @StPQW
    @StPQW Před rokem +2

    You rock!! 👑Thanks so much for your work!

  • @halitturanarican3434
    @halitturanarican3434 Před 17 dny

    Thank you very much. This cleared the concept for me :)

  • @theultimategamer7202
    @theultimategamer7202 Před rokem +2

    Great content as usual. Please upload video consistently

  • @mira10045
    @mira10045 Před rokem +4

    Please keep this JS series. I like your explanation!

    • @ColorCodeio
      @ColorCodeio  Před rokem +2

      It's going to continue :)

    • @hao12654
      @hao12654 Před rokem +1

      @@ColorCodeio really nice video, please do continue!

  • @tanjimulislamsabbir2264
    @tanjimulislamsabbir2264 Před měsícem +1

    Wow. That's a great one about promises. 💚

  • @EducationSimplified
    @EducationSimplified Před 6 měsíci +1

    Awesome explanation, I thought it was a difficult thing but you made it way tooo simple. Thank you for your time and efforts. God may bless you a lot.❤❤

  • @matickovac
    @matickovac Před rokem +2

    This is by far the best explanation on the topic I have been able to find, and I must say I love your other videos as well. Love the production quality too, what is the recording software you're using, looks really slick?

    • @ColorCodeio
      @ColorCodeio  Před rokem

      The animations are all done by hand. The screen recording is just basic QuickTime.

  • @philliam111
    @philliam111 Před 10 měsíci +1

    very underrated channel! glad i found you

  • @johnforeverrules
    @johnforeverrules Před rokem +1

    thank you so much Mr Sina. Promises confused me a lot. God bless

  • @avigarg7859
    @avigarg7859 Před 11 měsíci +1

    You teach so creatively

  • @pandorofortes9309
    @pandorofortes9309 Před 10 měsíci +2

    Thank you for the knowledge😁😁😁
    Your channel is🔥🔥🔥🔥🔥

  • @Walid-Sahab
    @Walid-Sahab Před rokem +1

    How much effort you put for a single video other CZcamsrs don't even put to build their whole channel.

  • @Walid-Sahab
    @Walid-Sahab Před rokem

    جانی بہترین ہوگیا 🔥 🤍

  • @sujith.m.s4041
    @sujith.m.s4041 Před 8 měsíci +1

    I got stuck in promise and call back for like 2 days, this reslly helped a lot

  • @m.hakania2251
    @m.hakania2251 Před rokem +1

    You probably know and probably that's the reason you're making your videos this way, I love the way you constructed your videos!! (from a bro to bro comment)

  • @Gwgitu77
    @Gwgitu77 Před 4 měsíci

    Thanks for the clear explanation sir

  • @not.sardar
    @not.sardar Před 11 dny +1

    Thank you sir, very helpful!

  • @kayodekehinde3756
    @kayodekehinde3756 Před rokem +1

    Cheers what a beautiful Teaching thank you so much for this Video!!!

  • @cjplabs
    @cjplabs Před 2 měsíci

    I know this video is old, but i’ve been coming back to this “10 things you should know…” series every time one of these topics comes up in the Odin Project and they always just make everything click

  • @ariseawake3437
    @ariseawake3437 Před rokem +3

    I am giving a Promise that i will do practice and learn with this video ....Thank you

  • @yiroyi2894
    @yiroyi2894 Před rokem +1

    Your videos are amazing, very clear, it helped me a lot to finally understand the Promise concept

  • @th3ja
    @th3ja Před 5 měsíci +1

    Top notch content!

  • @nethunter1018
    @nethunter1018 Před rokem

    Love the way you explain everything.❤❤ Can you make a video on hoisting in javascript and stuff like javascript execution context.

  • @m47h4r
    @m47h4r Před 8 měsíci +1

    29:10 A usecase for passing in onError in the .then() is to provide fallback data. For example, if fun1 rejects and then if the onError returns some data, then having fun1().then(fun2, onError).then(onSuccess) means that the onSuccess function will always receive some data, either fun1 resolves successfully and it's all good and well, or onError happens and that provides a fallback value so that onSuccess can always assume it has some data.

  • @TsipporahtheExplorer
    @TsipporahtheExplorer Před rokem

    "im sick and tired of your broken promises, promises" -3LW Thanks for always upholding your end of the promise Sina!

  • @milad2424
    @milad2424 Před rokem +1

    عالی سینا جان موفق باشی رفیق قدیمی

  • @CondeAlberto
    @CondeAlberto Před rokem +1

    Waiting for episode 13... Qoly!
    Thank you for the video.

  • @xenocampanoli815
    @xenocampanoli815 Před 8 měsíci +1

    BTW your "do it yourself" admonition reminds me of the advice at the beginning of all the old Charles Berlitz language tapes where he said: Read it, Hear it, Speak it. He may have also said "Write it" sometimes, but his point was memory reinforcement that is as functional as possible.

  • @sunraiii
    @sunraiii Před 8 měsíci +1

    Tell me you play the bass without telling me you play the bass :D
    Thanks for this video series on JS. Great production quality, easy to understand and even entertaining at times!

  • @sameershende7770
    @sameershende7770 Před 5 měsíci +1

    Thank you so much. I was really confused on this topic but now I am confident with it.
    I PROMISE 😅😂.