This video covers the new ES8 “async” and “await” keywords for writing asynchronous functions in JavaScript.
🎥 Next Video: https://youtu.be/chavThlNz3s
🔗 async on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
🚂 Website: http://thecodingtrain.com/
💖 Patreon: https://patreon.com/codingtrain
🛒 Store: https://www.designbyhumans.com/shop/codingtrain/
📚 Book recommendations: https://www.amazon.com/shop/thecodingtrain
💻 https://github.com/CodingTrain/website
🎥 For more videos on ES6/JavaScript: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6YgpA3Oht-7B4NBQwFVe3pr
🎥 For more Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
🔗 https://p5js.org/
🔗 https://processing.org
Original source
33 responses to “16.13: async/await Part 1 – Topics of JavaScript/ES8”
@TheCodingTrain Daniel, beware that you properly return the expected Promise! At 4:50, your async function returns NOTHING, but the code executes anyway because the function does return a Promise internally. The issue you'd have is that the delay function gets's called, but if you expect to pass down a return value from the delay function, you would've lose that value, here. Unless the behavior is documented, you should return a value inside a promise chain.
It is also important to note that promises are also recursive (DFS)! And you can still chain a promise AFTER a catch handler.
How many active timers can a Javascript program have? What if you need more than one? Btw- your tutorials are excellent!
When confusing turns into more confusing… I don't mind the errors over errors as it just creates more confusion. Can you "await" for something that isn't a promise?
"you can't just use 'await' anywhere in your code"…. of course javascript wouldn't allow something to be that easy.
Thank you! Very useful!
I really like the way you explain the concepts of async/await in this video!
I've created a video on my channel teaching async/await on a short real world project, feel free to check it out! 🙂
Thx man, you helped a lot!
thank you for teaching to people who dont have money to pay a university you're helping many people like me
<3
I think You are such an amazing person 🙂 <3
really nice way to teach
i wish u have tutorial on how to write a cypress testing cuz there was not much out there and i really like the way u explain things~ Thx for good vdo
personally i prefer async() module
You should be more confident about your work, your videos are awesome!
Please do a tetris coding challenge.
How can I "await" an Observable?
WE'RE @ ES8 ALREADY?!?!?!?!?!?! I'm not ready xD
Where you coding?
didn't quite understand async/await by that video. I think the example video will clarify things and I'll hopefully be able to understand then.
Love this episode, Dan!
Too short! hehehehe
Nice video, I really like the didactic way in which you explain things 🙂
I find it ironic that the modifier is "async" when what it effectively does is causes promises to operate synchronously… i.e. blocking. Or maybe I'm failing to understand. Keep up the great work!
You were right, this does seem a lot nicer to me 🙂
I like this a lot more than a bunch of thens.
You gave such a bad example.
You missed all the benefits of async/await
I love coding train
so its looks like Exception ??
FIRST!!!!
ur not boring like other I really like your video ur helpful thanks coding train (:
How about this:
async delayES8(time) {
try {
await delay(time);
createP('hello');
} catch (err) {
console.error(err);
}
}
Embed your .then, .catch into the async function.
async/await are exactly what I have always wanted. Why didn’t I learn these earlier. Goodbye chains of 50 then
Amazing brother!
Crikey, not sure whether I should spend the time learning promises or just move straight onto async/await =0