From the course: JavaScript: Async
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Understanding promises - JavaScript Tutorial
From the course: JavaScript: Async
Understanding promises
- Callbacks are really handy for basic cases where we want to execute additional code after an asynchronous function completes. And as you might imagine, it's even possible to string callbacks together pretty much as far as we need to. However, when we start working with code that uses multiple chain callbacks, it can be hard to write code that's both well-organized and easy for humans to read, to solve this problem. Modern JavaScript supports promises, which allow us to string together multiple callbacks while maintaining well-organized and human readable code. A promise is an object that represents the eventual result of an asynchronous operation. A promise contains information about the operation and tracks its status. It has a state property which can be pending fulfilled or rejected, and it has a result property which starts as undefined and can be given a value based on the operation. When the operation is…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Understanding promises2m 46s
-
(Locked)
Building asynchronous code with promises3m 59s
-
(Locked)
Appending methods to resolved promises2m 38s
-
(Locked)
Using catch methods for rejected promises3m 52s
-
(Locked)
Using the finally method for executing handlers3m 32s
-
(Locked)
Preparing the all method for executing multiple promises2m 16s
-
(Locked)
Implementing the all method for executing multiple promises6m 39s
-
(Locked)
Making code backward-compatible with polyfill1m 29s
-
(Locked)
-
-
-