From the course: Learning the JavaScript Language
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Promises, async, and await - JavaScript Tutorial
From the course: Learning the JavaScript Language
Promises, async, and await
- [Instructor] In this video, we're going to look at various approaches to writing asynchronous code, so you'll recognize these approaches in the wild. We'll look at using callbacks, promises, and the new async and await keywords. Here's some example code that uses these three approaches. The first one uses the get method from the jQuery JavaScript library which is a function that takes a URL as its first parameter and a callback function as its second. That callback gets the response from the server as its argument which you can then act on in the body of the function. These calls are to httpbin.org, a real website that provides an API for testing just this sort of code. This works fine for a single call but if there's another request that depends on the first one and maybe more after that, you end up having to nest all these callback functions within one another, and it gets to be a bit of a mess to write, and can be…
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Asynchronous code: Waiting is the hardest part2m 48s
-
(Locked)
Promises, async, and await3m 21s
-
(Locked)
Object-oriented JavaScript: Prototypes and classes3m 40s
-
(Locked)
Jargon: Strong vs. loosely typed1m 50s
-
(Locked)
Modern JavaScript tooling3m 50s
-
(Locked)
Responsible JavaScript4m 23s
-
(Locked)
-