JavaScript Promises In 10 Minutes

Поделиться
HTML-код
  • Опубликовано: 30 сен 2024

Комментарии • 1,5 тыс.

  • @WebDevSimplified
    @WebDevSimplified  5 лет назад +277

    If you enjoy promises make sure to checkout Async/Await.
    ruclips.net/video/V_Kr9OSfDeU/видео.html

    • @maxrockbin
      @maxrockbin 5 лет назад +1

      Did something go wrong with the video upload? I'm seeing your VS Code video instead of your JScript promises video

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад

      It sounds like a problem with RUclips. That has happened to me before. Just try refreshing the page. That usually fixes it for me.

    • @manishpingale6558
      @manishpingale6558 5 лет назад

      Can you create a video on firebase cloud functions

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +1

      I have never used firebase so I am not sure if I will cover it anytime soon

    • @mpey_project
      @mpey_project 5 лет назад

      is promise doesn't need to be declared first?

  • @WebDevSimplified
    @WebDevSimplified  5 лет назад +329

    watchThisVideo.then(() => celebrate()).catch(() => sadness())

    • @aishahale5504
      @aishahale5504 5 лет назад +8

      watchedTheVideo.then((data)=>{ }).catch((error)=>{ console.log("error: ", error) }); ..................... CONSOLE - error: "PERFECT PROMISE VIDEO FOR BEGINNERS"

    • @kevinm8865
      @kevinm8865 4 года назад

      @Đeath Vader lol

    • @DarkAcademyUniversity
      @DarkAcademyUniversity 3 месяца назад

      @@garrybogdanhoshame

  • @BobKeys-le9ih
    @BobKeys-le9ih 6 месяцев назад +1

    The first promise video that actually helped

  • @giftibe5268
    @giftibe5268 Год назад

    thanks man. you really hit the nail on the head, would be cool if you had an online course on one of these platforms. thanks

  • @bikramrawat3424
    @bikramrawat3424 3 года назад

    You are really capable of making complex things much simpler, the way you describe is awesome, definitely you resolved your promise to make best video ever on promise :)

  • @eduardohenriquedeassis9729
    @eduardohenriquedeassis9729 2 года назад

    Very good, as always!
    Greetings from Brazil.

  • @nimshanezio9083
    @nimshanezio9083 4 года назад

    Your videos are just like call stack. I started from the async wait video. Then here. Now I have to to go to another video.

    • @WebDevSimplified
      @WebDevSimplified  4 года назад

      I tried to cover a ton of different linked concepts in small digestible videos to make it easier to follow them all.

  • @tomgu1809
    @tomgu1809 2 года назад

    I promise to get my first JS job from Karl's training. If my dream resolved, then I will get a good pay and decent life, if the boss reject me, I will catch up, try another company or practice more.

  • @inesborges4857
    @inesborges4857 4 года назад +1

    Thank you for your video, but I didn't quite understand if promises are asynchronous or synchronous. Could also explain me why?

  • @pk-ds7gg
    @pk-ds7gg 2 года назад +1

    This is the best video ❤️❤️

  • @KinnD
    @KinnD 3 года назад

    Thanks man, you helped me a lot.

  • @SuperQuwertz
    @SuperQuwertz 3 года назад

    Me: How the F do I use an API?
    WebDevSimplified: Take my hand.

  • @tr.j4079
    @tr.j4079 3 года назад

    Video: JavaScript promises in 10 mins.
    Me: Checks video length - 11 min
    Also me: I guess promises are meant to be broken..

  • @csandreas1
    @csandreas1 4 года назад

    Your promise has been resolved !

  • @1polyron1
    @1polyron1 5 лет назад +1013

    "I promise to make the best video on promises I can."
    I like this guy.

    • @naynyamish270
      @naynyamish270 4 года назад +2

      "I promise to make a video on promises the best that I can" or "I promise to make , as best as i can , a video on promise " FTFY

    • @yansun3808
      @yansun3808 4 года назад

      Reject his promise. I am kidding :)

    • @atribhattacharyya2631
      @atribhattacharyya2631 4 года назад +5

      Resolved..:)

    • @JOc17KER
      @JOc17KER 4 года назад

      00:24

    • @gianfrancobriones
      @gianfrancobriones 7 месяцев назад

      He should've shown a sample of a minimum time consuming URL visit, not simple artithmetic 1 + 1. I don't like this tutotial. ~04:37

  • @returnZeroo
    @returnZeroo 5 лет назад +1189

    You resolve your promise, you make me fully understand

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +74

      I'm glad I could help

    • @joma0305
      @joma0305 4 года назад +16

      Sorry for my nooby question, i am more python guy, just starting my journey into js. But i didn't get what for you need "promises"? Why you just don't use "if statement"?

    • @Al_Gonzo
      @Al_Gonzo 4 года назад +6

      @@joma0305 watch the video one more time then because he explained it multiple times

    • @joma0305
      @joma0305 4 года назад +1

      @@Al_Gonzo i did ut before your comment. If you so smart pls explain

    • @joma0305
      @joma0305 4 года назад +1

      @@Al_Gonzo or it's just a "sugar" of js pl

  • @ThePazuzu
    @ThePazuzu 4 года назад +215

    When you're self taught your knowledge is all around the place, like you know classes, instantiation, scope, ES6, and a bunch of advanced stuff but don't know basic stuff like git. I'm in the middle of a very async heavy project on Express and was having a hard time with promises. I decided to take the WHOLE day off to look into it and it only took me 11 minutes thanks to this video. Now I can go back to my project with an extra day on my deadline. Thanks man, that was awesome!

    • @notdaveschannel9843
      @notdaveschannel9843 4 года назад +20

      "When you're self taught your knowledge is all around the place". Yeah, that's where I am with a lot of coding. I've been using 'async... await' and 'fetch' without really understanding the underlying 'Promise' object. Makes a lot more sense now!

    • @Meleeman011
      @Meleeman011 3 года назад

      express can do async now lol nice. i since moved on to koa but i use express for future devs that aren't me.

    • @jonathanr7603
      @jonathanr7603 6 месяцев назад

      @@notdaveschannel9843 async await is just syntatic sugar, you need to know promises instead

    • @mildracc6191
      @mildracc6191 2 месяца назад

      This is such a factual comment. Ive made 3d games with javascript that run in the browser, yet here I am, finally learning how promises work😂

  • @smoovewitit
    @smoovewitit 3 года назад +22

    How do you speak so flawlessly without pauses or ticks, all while typing out code with very few mistakes? Was this all one take? This shouldn't be possible

    • @cezartorescu
      @cezartorescu 2 месяца назад +3

      Smart people talk like this.

  • @davidvideauortega287
    @davidvideauortega287 5 лет назад +686

    After watching crashcourses, long, 45 min videos and articles about promises, I can say this is probably the only video that actually made me understand promises. Wonderfully explained! Thank you so much, you have a new subscriber :)
    And also... The amount of dislikes says it all.

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +27

      Thank you! I am really glad I could help.

    • @LFFebro
      @LFFebro 5 лет назад +5

      You took the same path as myself. I have been taking a marathon of Async Javascript to grasp on for once and for all.

    • @janithillangakoon6962
      @janithillangakoon6962 4 года назад

      same here

    • @animeshsharma7332
      @animeshsharma7332 4 года назад +23

      Even the official documentation by MDN sucked!!

    • @faizaanannoor395
      @faizaanannoor395 4 года назад

      @@animeshsharma7332 true that!

  • @jthomasaurus
    @jthomasaurus 4 года назад +61

    I’ve commented before, basically the same thing, but I REALLY enjoy your style of teaching. To the point, understandable examples, and clean code. This is by far the best video on Promises I’ve seen yet. Thank you!

  • @jamesonvparker
    @jamesonvparker 5 лет назад +164

    Dude.... that was a CLEAN tutorial. I can easily go back and watch it a few times to practice it. Writing a promise to console log 1,2 and 3, in order, asynchronously , was an interview question. I watched your video to re-learn the syntax. Thanks!

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +9

      I'm really glad the video was able to help!

    • @divinemasculine3730
      @divinemasculine3730 2 года назад +1

      hey man did you get the job?

    • @jamesonvparker
      @jamesonvparker 2 года назад +5

      @@divinemasculine3730 not only did I get that job. I have just recently accepted an offer from the company behind this very platform 😉.

    • @divinemasculine3730
      @divinemasculine3730 2 года назад +4

      @@jamesonvparker wow youtube??? so inpirational! can you give me tips? im from canada going through a FULL STACK coding bootcamp

    • @jamesonvparker
      @jamesonvparker 2 года назад +3

      @@divinemasculine3730 find me on linked in. I’ll talk there

  • @kvncnls
    @kvncnls 4 года назад +18

    Wow, this made much more sense than the udemy course I'm taking right now.

  • @mumblepie5367
    @mumblepie5367 4 года назад +16

    Also the .then can take two functions as arguments. The first one being done on resolve and the second one for reject. .catch is the same thing as .then(null, reject)

    • @DamianDemasi
      @DamianDemasi 3 года назад

      .catch is not exaclty the same, becasue you can use different a "reject" for every .then, and use a common .catch at the end of the chain to catch any unhandled error.

  • @mattwild3510
    @mattwild3510 2 года назад +2

    This is so confusing to understand

  • @threeone6012
    @threeone6012 5 лет назад +43

    The last 11 minutes and 30 seconds of my life was well spent.
    Great upload!

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +4

      Thank you so much! I'm glad you enjoyed it.

    • @samrad6508
      @samrad6508 4 года назад +8

      are you dead ?

    • @luke4502
      @luke4502 4 года назад +4

      RIP

    • @skiddykakaka9423
      @skiddykakaka9423 4 года назад +4

      rest in rip

    • @Al_Gonzo
      @Al_Gonzo 4 года назад +4

      The guy liked this 11:31 long video so much that his profile picture is now his new favorite numbers, "3" and "1".

  • @SneakyTars
    @SneakyTars 6 месяцев назад +2

    new Promise((resolve,reject)=>{
    let a = 1
    if(a==1){resolve("you taught me well")}
    })

  • @theannoyingone110
    @theannoyingone110 Год назад +13

    I am a very young programmer and Kyle will always be my favorite programming RUclipsr out there.

  • @macroxela
    @macroxela 4 года назад +14

    I've been binge watching your videos and they are wonderful. Not too long and not too short while delivering the content clearly. Keep up the good work!!

  • @andrewc95
    @andrewc95 Год назад +8

    Bro, been trying to understand this for an hour. Your video was the first where it all clicked. Thanks!

  • @georgecraciun-vasilache3921
    @georgecraciun-vasilache3921 5 лет назад +13

    You definitely kept your promise about the video. Good work!

  • @techuchiha6510
    @techuchiha6510 5 лет назад +19

    This channel is massively underrated 🙌🏻

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +2

      Thanks! I think 4,000 is a pretty huge number already, but I am excited to see what the future holds.

    • @techuchiha6510
      @techuchiha6510 4 года назад +1

      See this is what I was talking about!!! Way to go buddy!!!

    • @vmusatov
      @vmusatov 3 года назад

      @@udeleted almost doubled 3 months later. Race for a million. I’m a new sub

  • @galinmalchev1739
    @galinmalchev1739 Год назад +6

    I started learning development with udemy courses. It all went great and I've been through 2 interviews so far.
    In one of the interviews they told me to learn the theory behind promises and it turned out that I've used it many times but that video really helped me solidify the knowledge and understand the actual logic behind them.
    I always seek your short and straight-to-the point tutorials for similar cases.
    Thank you.

  • @4aLse
    @4aLse 2 года назад +1

    thanks for simplifying promises concept, this is a great video for sure.

  • @Samuel.Collier
    @Samuel.Collier 5 лет назад +13

    "...and that cats are better than me"
    🤣
    Thanks for your help

  • @miladevs
    @miladevs 4 месяца назад +1

    Great explanation of promises, Kyle! Using Promise.all and Promise.race really helps in managing multiple asynchronous operations efficiently. For those looking to write cleaner and more maintainable code, promises are a game-changer compared to traditional callbacks. Thanks for breaking it down so clearly!

  • @johnchase9054
    @johnchase9054 5 лет назад +21

    The promise code for the first example gave me a “Promise {}” when a = 2. It gave me the correct result when a = 3. Ran straight and with localhost. Both were the same, thoughts?

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +22

      It sounds like your promise is never calling resolve or reject. You might want to check to make sure that your if logic is correctly setup so that either resolve or reject are always called inside your promise.

    • @techhousemedia8727
      @techhousemedia8727 3 года назад +2

      Promise has three states which are; 1. Pending, 2. fulfilled and 3. reject. when you defined a promise in a function, that function remains in a pending state untill you run the code and now result in a certain condition base on your logic, that is when the function will enter into being fulfilled or rejected.

    • @FaceMaskHenry
      @FaceMaskHenry 3 года назад

      you can try "Promise(**).then(**).then(**)". Means try to see in second "then"

  • @mostinho7
    @mostinho7 2 года назад +1

    Done thanks
    Promise is itself declared as new Promise((resolve, reject) => {//promise logic here}), takes a function as parameter, that function takes two functions/callbacks resolve and reject.
    The logic of the promise itself is defined in the callback that the promise was initialized with, which calls the resolve or reject callback.
    The caller of the promise can call .then(theParamResolveGot => {
    //the resolve logic}) passing it a callback which takes the same parameter that is passed to the resolve callback inside the Promise.
    Calling .catch(theParamRejectGot => {//logic to handle rejected promise})
    Can then chain callback after callback by chaining .then which avoids callback hell

  • @suchetasarkar7299
    @suchetasarkar7299 2 года назад +10

    I am learning a lot from you . Your videos are always to the point . As a self taught programmer, this channel is a gem . Thank you so much : )

    • @helvosthecreator1920
      @helvosthecreator1920 8 месяцев назад

      So how did your self taught programmer journey go? Asking for a friend 😂

  • @Ren-Ren-Ren-Ren
    @Ren-Ren-Ren-Ren 2 года назад +1

    Just learned about callbacks. Then I realized there is a better way called Promises. Now that I learned promises, I realized there is syntactic sugar for promise.then().catch() called async/await.
    Learning programming is a rabbit hole!

  • @jordirhoden300
    @jordirhoden300 5 лет назад +6

    Dude, your tutorials are amazing. Thanks for everything you teach us. Greetings from Costa Rica

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +5

      Thank you! It always amazes me how many people from all over the world have seen one of my videos.

  • @stith_pragya
    @stith_pragya Год назад +1

    Thank You So Much for this wonderfull video................🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @alexdorrington
    @alexdorrington 4 года назад +4

    So like
    then ==> runs for resolve
    and
    catch ===> runs for reject

  • @hettdo
    @hettdo 9 месяцев назад +1

    question, can the 'message' can be change to any other word, or 'message' is a function? I'm doing a course, and it's using 'result' instead of your example 'message'. Thank you.

  • @DJDELLANNIE
    @DJDELLANNIE 2 года назад +4

    I read the entire MDN section on Promises and 11 mins convert me into a promise pro thank you sir

  • @justinstarr1667
    @justinstarr1667 2 года назад +2

    Just a reminder that Callback Hell IS a real place where you WILL be sent at the first missing curly brace.
    In all seriousness though, great walkthrough!

  • @RoshanKrSoni
    @RoshanKrSoni 5 лет назад +7

    Dislikers thinking that button is for download this 😂

  • @Vikram-wx4hg
    @Vikram-wx4hg 3 года назад +1

    We have an expression in the Hindi language for the way you explained the things here: "Kya Baat Hai!" (which mean "How brilliant!")

  • @Zephyr-tg9hu
    @Zephyr-tg9hu 4 года назад +13

    I really went down the rabbit hole with this one... Was initially learning about CPU hyperthreading and got confused between concurrency, parallelism, and sync and async tasks. Learning that introduced me to asynchronous code, which finally led me here. I don't even know JS lol.
    Really good video! I found this quite interesting.

  • @zachariahkerner7896
    @zachariahkerner7896 Год назад +1

    Promised half fulfilled. It would have been nice to see some examples with asynchronous operations. The examples felt a bit contrived.

  • @CaliburPANDAs
    @CaliburPANDAs 2 года назад +4

    guy explained in 11 mins what took hours for my instructor. thank you 🙏

  • @Sigma_reality614
    @Sigma_reality614 2 года назад +1

    Istg, i am super happy now... I COULD FINALLY UNDERTAND PROMISES

  • @LFFebro
    @LFFebro 5 лет назад +6

    Yeah. This is the best video from my Async JS marathon. Superb, right-to-the-point and practical explanations. You did, pal. One more subscriber. Keep up the good work!

  • @henryandnancy3018
    @henryandnancy3018 4 месяца назад +1

    This video within 3 minutes explained everything about promises.

  • @uhN0id
    @uhN0id 5 лет назад +4

    Fantastic explanation! My only feedback is to increase the font size in your editor for those of us watching on mobile (and I'm sure desktop would benefit) when doing these smaller examples. Would be a lot easier to read.

  • @Xeratas
    @Xeratas 2 года назад +1

    Do you have a tutorial for fetching a json from an api with a promise? i am getting so confused and i don't even understand why. I will try it again now that i watched this video. Anyway if you have a specific video on fetch and promise let me know

  • @harishkandikatla9791
    @harishkandikatla9791 5 лет назад +12

    I watched 4-5 other videos about callbacks, promises before watching this video, was not satisfied. I am very much satisfied with your explanation in just 10 mins. Great 👍

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +6

      Thank you! I try to make all my videos as concise and informational as possible. My goal is the be the channel with the most learning per minute of content.

    • @chris94kennedy
      @chris94kennedy 4 года назад +1

      @@WebDevSimplified Yeah think we can all agree you're pulling that one off. Congrats on your engagement also, huge

  • @HighEntertainer
    @HighEntertainer 9 месяцев назад +1

    Thanks bro it was really helpful I generally don't leave a comment but his channel is a hidden gem bro thank you❤

  • @rmewse3616
    @rmewse3616 5 лет назад +4

    This is amazing! Thank you so much 😊. You explained this perfectly. I have been trying to learn this for weeks and I’ve been failing but I just learned it in 10 minutes! I completely understand this now, thank you! YOU HAVE A NEW SUBSCRIBER 😄😄

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +1

      Thank you so much! I am really glad I could help, and I hope my other videos are just as helpful.

    • @rmewse3616
      @rmewse3616 5 лет назад +1

      Web Dev Simplified thank you

  • @mithrandir2171
    @mithrandir2171 3 года назад +1

    I LOVE YOU KYLE! (no homo hahahaha)
    THANK YOU SO MUCH MAN! YOU REALLY MADE IT VERY SIMPLE TO UNDERSTAND THIS TOPIC! 😍😂😘😘

  • @jandeswart1378
    @jandeswart1378 4 года назад +6

    Awesome!
    I have been struggling with this subject for a whole week. I read every resource I could find on the internet. This video finally made me understand promises in a matter of 5 minutes.

  • @v4runs
    @v4runs 5 лет назад +9

    That feeling as a Java developer to see statements ending without semi-colon...

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +1

      It is a great feeling.

    • @DutchRatedGamers
      @DutchRatedGamers 5 лет назад +2

      @@WebDevSimplified While I like it, I consider it a bad practise whether it's allowed or not.
      But I find JS rather messed up anyway.
      -- Don't attack me on it though, I use it when needed (Which is currently using NodeJS + Electron).

  • @ajaythombare6235
    @ajaythombare6235 Год назад +1

    so we can execute the functions in parallel but how isnt Javascript is single threaded

  • @esofialo23
    @esofialo23 3 года назад +8

    Thank you so much for your videos! You have a great talent for teaching :D I wish college teachers were like this, mine would only read their PPT in class :(

  • @BelegaerTheGreat
    @BelegaerTheGreat 3 года назад +1

    Man, my only request is for you to speak faster, except that it's great.

  • @Fatalitron
    @Fatalitron 5 лет назад +8

    I learned more about promises from this ten-minute video than I did from an entire fifteen week web dev course in school. Can't thank you enough!

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +1

      I'm really glad I could help!

    • @GMIX
      @GMIX 5 лет назад

      Web deb course in school? I could only dream about this. The only thing i've learnt from school is how to open ms word.

  • @kshitijsharma2121
    @kshitijsharma2121 2 года назад +5

    Why do all coding tutorials have these comments like 'super simple explanantion' "best video ever" ...no matter how bad the explanation was. It will always be a mystery to me

  • @KingKhan-bi7kb
    @KingKhan-bi7kb 4 года назад +1

    That really helped. Thanks from India.👍👍

  • @maksymkloka5016
    @maksymkloka5016 2 года назад +6

    Ok. Two things: 1) slow down about 2-3x. 2). As someone that is being forced to take JavaScrip for a CS major, I can't help but notice how terribly JavaScrip is compared to other programming languages... literally feels like a house made of scraps ... there just isn't any clear consistency or common sense built into this language ... it's all just a bunch of strung together libraries and weird syntax that was build over whatever was there before ... everything seems to be based on word of mouth and experience rather than the structured and consistent approach used by other programming languages. I thought Python was terrible, but JavaScrip takes it to the next level of confusion. Somehow the claim is that this makes things faster and easier, but all I see is a bunch of unnecessary complexity that could be simplified by going back to the basics.

    • @ITSplit
      @ITSplit 10 месяцев назад

      You are so right about this!

    • @karthickselvam8606
      @karthickselvam8606 10 месяцев назад

      Dude Javascript is a language that was built for browsers initially.Today the many versions of JS introduced new syntax which is confusing but there is a reason behind the weird things of JS. Its cause of 2 things they are doing at the same time, one is they don't want to break the code written a long time ago another is they are making development easy for the devs by implementing new features and syntaxes..Javascript should have a backward compatibility always.

    • @Henry_Red
      @Henry_Red 8 месяцев назад +1

      Bro, what are you talking about? I had to put the video in 1.25x because it was too slow.

  • @dustingarner4620
    @dustingarner4620 2 месяца назад +1

    This was very helpful, thank you!

  • @petruciucur
    @petruciucur 6 месяцев назад +2

    Not simple at all 😁

  • @akhmedbejli8657
    @akhmedbejli8657 4 года назад +1

    So...the Promise method is just an if/else statement?

  • @codefrite
    @codefrite 2 года назад +1

    Great Video ! Thank you so much :)

  • @SoraFromIndia
    @SoraFromIndia 3 года назад +2

    Alright, this is official now. I MugenSora, declare you the best out there.

  • @Johan-b4l
    @Johan-b4l 4 года назад +1

    What is the difference?
    - use 2 callbacks in then: then(onfulfilled, onrejected)
    - using only catch: catch(onrejected)

    • @akashgupta1353
      @akashgupta1353 4 года назад

      The result will be same but we use catch because of readability and clean code.

    • @Johan-b4l
      @Johan-b4l 4 года назад +1

      @@akashgupta1353 okay. Thanks for the reply.

  • @mocococo2877
    @mocococo2877 4 года назад +1

    I do no know how to say it - as some months ago you payed attention to my question and responded very promptly. I am very thankful for that.
    I saw other sources saying that Catch is not for catching Reject state, although it works there too. Catch should be for catching an unexpected error. Rather Then has (or can have) two functions as parameters - first one for Resolve, the second for Reject.
    Could you elaborate on that
    I hope I am bringing a constructive question.

  • @footballarena6562
    @footballarena6562 4 года назад +2

    This tutorial was like revisiting form basics to learn to pro. I read some articles about Promises and I sort of knew what this was about. But the way he gave the example, this just got stuck in my mind. thanks man

  • @a_maxed_out_handle_of_30_chars
    @a_maxed_out_handle_of_30_chars Год назад +1

    thank you, simple and to the point :)

  • @omar-elgammal
    @omar-elgammal Год назад +1

    The best video on promises I came across !

  • @DivineZeal
    @DivineZeal 3 года назад

    I love you for this video. Wtf callback hell, go back to your prison!!!!

  • @ravichandra183
    @ravichandra183 2 месяца назад +1

    Awesome explanation, thanks

  • @filintodelgado
    @filintodelgado 2 года назад +1

    Finally I understand this, not afraid of promises anymore.
    Always keep your promise guys.

  • @abdihakim391
    @abdihakim391 2 года назад +1

    You really simplified my javascript learning journey
    thank you kyle, Hats off for you 🎩

  • @gerompauel
    @gerompauel 2 года назад +1

    Absolutely unclear topic 🤪

  • @muhammadparacha
    @muhammadparacha 2 года назад +1

    Omg your a life saver :) tysm

  • @fighter8931
    @fighter8931 8 месяцев назад +2

    Your video is 5 years old, But I think it’s still the best.

  • @ppg68
    @ppg68 4 года назад +1

    So it's basically a try-catch-finally statement like in c#?

    • @csandreas1
      @csandreas1 4 года назад

      It's a re-callable try-catch. Promises give you the freedom to do anything you want when you call them in the then-catch callbacks

  • @adityaghosh6170
    @adityaghosh6170 9 месяцев назад +1

    Probably the best video on RUclips that explains promises in such a lucid fashion. Liked, commented, subscribed and shared as well. Keep up the good work man.

  • @nigelflim
    @nigelflim 4 года назад +2

    Been stuck on learning Promises as a beginner and this has helped tremendously! Cheers!

  • @carafachera4781
    @carafachera4781 Год назад +2

    Thks for existing my beloved teacher😍

  • @ArifBillahOnGoogle
    @ArifBillahOnGoogle 4 дня назад

    For those of you being confused about the syntax, just ignore the passing of "resolve, reject" into the promise callback as parameters. Long story short, JS engines could have done just fine without requiring the explicit passing of these two parameters as they serve literally no practical purpose ever. Don't know why they made the syntax like this, but yea ignore these two parameters from your mental model, and all of a sudden, the syntax will look like any standard JS API syntax.

  • @johnnasimba3597
    @johnnasimba3597 4 года назад +2

    This is the most important video I have watched today so far

  • @dannjohnrem
    @dannjohnrem 4 года назад +1

    The parameters of the promise can be rename or it is default? Thanks

  • @veremox
    @veremox 3 года назад +1

    i fucking love you man god damnit

  • @pritulkhan1395
    @pritulkhan1395 4 года назад +1

    You have fulfilled the promise of conveying the tutorial of "Promises" in a very promising manner. I have liked, comment and subscribed :D

  •  4 года назад

    FYI I get this msg when I typed the program as at 3:54:
    (node:10099) UnhandledPromiseRejectionWarning: ReferenceError: Cannot access 'p' before initialization
    at /home/kemal/WDS/promise.js:11:1
    at new Promise ()
    at Object. (/home/kemal/WDS/promise.js:1:9)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47
    (node:10099) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
    (node:10099) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

  • @johnpummill9443
    @johnpummill9443 2 года назад

    At 10:17 you discuss that promise.all() runs all three promises at the same time but when I try the following it still lists the output in the order that the promises are listed even though promis1 takes 5 seconds while the other two finish almost instantly:
    ---
    const promise1 = new Promise((resolve, reject) => {
    setTimeout(resolve, 5000, 'foo');
    });
    const promise2 = Promise.resolve(3);
    const promise3 = 42;
    Promise.all([promise1, promise2, promise3]).then((values) => {
    console.log(values);
    });
    // output: Array ["foo", 3, 42"]
    ---

  • @lerneninverschiedenenforme7513
    @lerneninverschiedenenforme7513 3 года назад

    regarding async/await, this was also very helpful: tutorialedge.net/typescript/async-await-in-typescript-tutorial/

  • @misterl8129
    @misterl8129 3 года назад

    Hi! can you do a video of a promise all but WITH async/await pls like
    let arrayofData = [infoA, infoB, infoC]
    Promise.all(arrayofData.map(async(data,i)=>{
    let res = await someRandomApiCallWithDifferentDelayTimes()
    return res
    }))

  • @toddhoward5947
    @toddhoward5947 4 года назад

    i deconstructed the callback fun used in this video this will avoid all the confusions
    const userLeft = false;
    const catMeme = false;
    function watchTuts(call, error){
    if(userLeft){
    return error( obj1);
    }else if(catMeme){
    return error(obj2);
    }else{
    return call();
    }
    }
    function callback(){
    return 'thumbs up'
    }
    function errorCallback(object){
    return ` ${object.name} ${object.message}`;
    }
    const obj1 = {
    name: 'user left',
    message: 'sad'
    }
    const obj2 = {
    name: 'cat meme',
    message: 'depressed'
    }
    console.log(watchTuts(callback, errorCallback));

  • @DC1YellowPenguin
    @DC1YellowPenguin Год назад

    why do you use "catch()"? Cant you just do" p.then((message) => {console.log(" " + message)}), (message) => {console.log(" " + message)});? Or do you need to have a print function instead of console.log to do that?