Join Eve Porcello for an in-depth discussion in this video Intro to promises, part of Learning ECMAScript 6.
- [Instructor] Promises have emerged in the S6 to help…us deal with asynchronous behavior in JavaScript.…When something is asynchronous it means that…some sort of weighting is going on.…There's a delay between when we ask for…something and when we receive it.…To create a promise, I'm going to create…a function called delay.…And what delay is going to do is it's…going to return a new promise.…So here I'm going to use seconds as…our argument, and our function is going…to return a new promise.…Now, this new promise is going to take in…a very important argument, which is resolve.…
So this is what's going to occur whenever…the promise resolves, whenever it is successful.…And in this case, we're going to set a timeout here,…and setTimeout is going to obviously take in…two things: it's going to take in a callback…function, which in this case is resolve; and…it's going to take in the number of milliseconds…before we timeout.…So here we'll say seconds times 1000.…So this is going to return those milliseconds for us.…
Okay, so let's console.log a little message…
Author
Updated
10/6/2017Released
1/5/2016- What is ECMAScript?
- Transpiling ECMAScript with Babel and Babel-node
- Using the let and const keywords
- Creating strings with template strings
- Enhancing object literals
- Working with ES6 classes and class inheritance
Skill Level Beginner
Duration
Views
Q: The Babel API is out of date. How do I proceed with the course?
A: We are updating the course. In the meantime, you can install the babel-cli package and then install the presets that you need to follow along with the tutorials.
Related Courses
-
Building a Polling App with Socket IO and React.js
with Alex Banks3h 56m Intermediate
-
Introduction
-
Welcome47s
-
-
1. What Is ECMAScript 6 (ES6)?
-
What is ECMAScript 6?1m 29s
-
ES6 browser support1m 14s
-
Using ES6 now1m 6s
-
-
2. Transpiling ES6
-
In-browser Babel transpiling2m 25s
-
Transpiling with webpack6m 23s
-
Migrating to webpack 35m 47s
-
3. ES6 Syntax
-
Let keyword5m 47s
-
Const keyword3m 8s
-
Template strings5m 9s
-
Spread operators2m 17s
-
Maps5m 9s
-
Sets4m 24s
-
The for...of loop4m 37s
-
-
4. ES6 Functions & Objects
-
Default function parameters2m 44s
-
Enhancing object literals4m 27s
-
Arrow functions1m 56s
-
Destructuring assignment6m 22s
-
Generators6m 59s
-
Symbols3m 39s
-
Iterators6m 32s
-
-
5. Asynchronous Features
-
Intro to promises6m 39s
-
Building promises4m 17s
-
Loading data with fetch5m 15s
-
Async and await4m 28s
-
Async with fetch4m 48s
-
-
6. ES6 Classes
-
ES6 class syntax2m 37s
-
Class inheritance2m 9s
-
Getters and setters4m 52s
-
-
Conclusion
-
Next steps38s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Intro to promises