An executor function is passed to the built-in Promise constructor. It runs immediately when the Promise is created and receives resolve and reject callbacks, which it calls to signal success or failure. section 6.3
Listing 6.10. Creating a simple promise
const ninjaPromise = new Promise((resolve, reject) => { #A
resolve("Hattori"); #B
//reject("An error resolving a promise!"); #B
});
ninjaPromise.then(ninja => { #C
assert(ninja === "Hattori", "We were promised Hattori!"); #C
}, err => { #D
fail("There shouldn't be an error") #D
}); #D
See an executor resolve a Promise with a value, followed by success and failure callbacks passed to then. section 6.3
