Created
July 5, 2017 10:15
The ES6 Promise Constructor And Its Executor Function Are Invoked Synchronously
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
console.log( "Start." ); | |
// Check to see that Promise constructor is executed synchronously. | |
var promise = new Promise( | |
function( resolve, reject ) { | |
console.log( "In Promise constructor." ); | |
resolve( "Future value." ); | |
} | |
); | |
// Check to see that Promise resolution handlers are invoked asynchronously. | |
promise.then( | |
function( result ) { | |
console.log( "Promise resolution:", result ); | |
} | |
); | |
console.log( "End." ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment