Created
January 19, 2017 22:16
-
-
Save ericelliott/2a1fa460e3e8330c5a2cad87acccb015 to your computer and use it in GitHub Desktop.
Wait -- an ES6 promise example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const wait = time => new Promise((resolve) => setTimeout(resolve, time)); | |
wait(3000).then(() => console.log('Hello!')); // 'Hello!' |
const wait = function(time) {
return new Promise(function(resolve) {
setTimeout(resolve, time)
})
}
wait(3000)
.then(function() {
console.log('Hello!');
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, could you please help explain "const wait '= time =>' new Promise" especially the statements enclosed in single quote and how they related to the whole line of code ..
Thanks..