Skip to content

Instantly share code, notes, and snippets.

@bennadel
Created July 5, 2017 10:15
The ES6 Promise Constructor And Its Executor Function Are Invoked Synchronously
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