JavaScript Promises Crash Course

preview_player
Показать описание

⌚ Timestamps
00:00 - Introduction
01:40 - Creating a promise
03:50 - Errors and catch
05:20 - Chaining multiple methods
07:42 - Using finally
08:54 - Practical examples
14:05 - async and await
16:45 - gotchas with async and await
22:00 - Which approach should you use?

#css

--

Come hang out with other dev's in my Discord Community

Keep up to date with everything I'm up to

Come hang out with me live every Monday on Twitch!

---

Help support my channel

---

---

I'm on some other places on the internet too!

If you'd like a behind the scenes and previews of what's coming up on my YouTube channel, make sure to follow me on Instagram and Twitter.

---

And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!
Рекомендации по теме
Комментарии
Автор

I wish Chris has a YouTube channel with lessons like this. The way he explains JS is so easy to absorb and understand.

teugene
Автор

Please please more JavaScript tutorials. This is good stuff always in demand.

BMikel
Автор

One thing that was skirted around but not touched on is that a promise saved to a variable but isn't chained will cache it's value for future then's, making it perfect for caching since most caches only check if the value exists and sends another request, not if the value is being fetched. Eg:

const question = Promise.resolve(42)

question.then(answer => console.log(answer))
question.then(answer => console.log(answer))

You get 42 logged twice, but if you were to chain them instead, the second would log undefined since nothing is returned from the first.

Great video too, keep it up.

LordValtrius
Автор

Kevin, thanks for having Christopher on to explain Javascript promises. He did a great job!

raystorer
Автор

Chris is a great teacher, but I'd love to see you engage more in the topic when you have guests on! Maybe re-contextualize the subject in a way that was helpful for you, or ask questions that you think a beginner might ask.

Love the videos, Kevin. Thanks!

tazerah
Автор

This was a great explanation and definitely furthered my understanding. Please make more JavaScript videos like this, they help so much. Many thanks!

markayyy
Автор

I'm really loving these JavaScript videos. The timing is perfect for me because I'm refreshing my skills before going out for a job. Chris is one of the best teachers I've ever seen for this. Very organized and clearly communicated.

bryanmyers
Автор

Saw the title of this and instantly started preparing my braincell to be blown away. This is a topic I've struggled with from the moment they were introduced.

daveturnbull
Автор

Really good video, thank you both for taking the time to record it!

flpflpflp
Автор

I pumped my fist when I saw the notification, promises been giving me a tough time. Thanks for this kev

osamudiameh_sama
Автор

clear and precise with increasing complexitiy. More stuff like this ! 🙏

mathiascunault
Автор

I don't know why people keep saying in tutorials that applying the .json() method to a response (for example) gives you a JSON object, when actually it returns a JS object (plain old regular object). That must confuse a lot of people

whatisthis__
Автор

I love that you are doing these javascript dives but if I wanted a dictionary definition of these things, I can just read a dictionary. This didn't answer the questions that I needed answered for me to actually understand promises. I needed him to explain what people did before promises existed. How did they get stuff done without a promise style function and how did promises then improve their life using examples. I also needed to get more real world situations where a developer comes across an issue and thinks, "this is exactly where I should use a promise." I write javascript web apps myself and I have never used a promise. Should I be using them? Why, if I am already living life without them? How can they help me. He needed to show code solutions without promises and then show the problematic nature of that and then bring along the hero "dun dda da dan !!! The Promise!" and show how that brings light to the problem. All he does in these videos is read from a dictionary of what a promise is. that is not helpful. Please make the video again but do it in the format that I have suggested here.

hoshi
Автор

Thanks kevin and Chris, finally understand promises and async await functions, greetings from Argentina!!

jonux
Автор

i genuinely admire you guys for all the knowledge you give us! thanks so much Kevin and Chris! 🎉

aditideshpande
Автор

If you ever hear someone talking about a function’s color, it is just saying that asynchronous and synchronous functions are a different “color” and you can only use synchronous functions inside asynchronous ones, but not the other way around. It is just easier to remember that async doesn’t return a value directly, so to wait for it, but to be able to do anything else, you will also need to wait for the parent function as well, all the way until the top function is reached. This is one of the most common issues new developers encounter and have difficulty with understanding.

This video didn’t explain how asynchronous functions work inside the JavaScript runtime, but the simple explanation is that there are three ways functions return a value: just calling a regular, callback for an event, or resolving a promise. So, there is a loop that checks stacks for code to run and it has to check three of them, the first stack is ran immediately, and the next two are added to the first when the condition has been met — like the event being triggered or the promise resolved/rejected. That is why you can’t call asynchronous functions inside synchronous ones, they don’t exist yet in the stack and will only exist after the next iteration of the loop.

jfftck
Автор

Today I learned about "finally." Finally! Personally, I prefer the async/await approach as that is how I first began to understand Promises.

bobmonsour
Автор

Async, Await. It’s not the dark ages.

JohnSmith-opls
Автор

I love those. I was hoping he'd mention how promises returned from another promise kinda automagically get then()'ed, because it really tripped me up when I was first learning promises, and honestly I still to this day didn't manage to wrap my head around it.

ittixen
Автор

Loved this tutorial!! Please more of this.

modi_hemnt