JavaScript Callbacks, Promises, and Async Await - How to Return a Response from an Asynchronous call

preview_player
Показать описание
In this video, we look at how to return a response from an asynchronous call in JavaScript. If you are trying to return a value from your asynchronous function in JavaScript and you are getting undefined as the value then this is the video that you must watch. It covers all the methods that you need to know in order to return a value from an asynchronous call in JavaScript. We compare JavaScript Callbacks vs JavaScript Promises vs Async Await in Javascript and see where to use which pattern to deal with Asynchronous requests in JavaScript.

📖 Video Chapters
00:00 Video Intro
00:19 Difference between asynchronous and synchronous functions
00:32 Understanding synchronous functions
01:48 Understanding asynchronous functions
03:26 Faking an asynchronous call
04:35 Callback Functions Explained
08:01 Promises in JavaScirpt
11:57 Async Await In JavaScript
Рекомендации по теме
Комментарии
Автор

why and how you put add(a:1, b:2) notation, why it is used ? ( a:1 notation)

sushantbhargav
Автор

But how can we return the sum outside of the async function? We can console.log the desired result here, but it's useless if we can't assign it to a global variable.

darrellleong
Автор

Thanks a lot for uploading this video. It made a lot of concepts clear in one go. Just wanted to ask if this approach can be used to export values from a module to another? E.g. If rather console logging, I want to export the value of the variable 'sum' from this module to another and print it there, will this approach still work?

The.SpiritualScientist