Search⌘ K
AI Features

Creating Promises in ES6

Understand how to create promises in ES6, control their fulfillment and rejection with resolve and reject functions, and manage asynchronous code effectively.

We'll cover the following...

Consider the following code:

Node.js
let promise1 = new Promise( function( resolve, reject ) {
// call resolve( value ) to resolve a promise
// call reject( reason ) to reject a promise
} );
// Create a resolved promise
let promise2 = Promise.resolve( 5 );
console.log(promise1)
console.log(promise2)

When instantiating a promise, the ...