Created
November 12, 2017 02:14
-
-
Save kurtroberts/3322db46c99cef6d18e050ff3b22350c to your computer and use it in GitHub Desktop.
One-stop understanding of Promises...
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
//TL;DR - Read the MDN page and skip all the tutorials: | |
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise | |
//ES6 | |
var x = new Promise((resolve, reject) => { | |
setTimeout(function () { resolve('test'); }, 5000); | |
}); | |
x.then((msg) => console.log(msg)); | |
//result - after 5 seconds, writes 'test' to STDOUT and exits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment