-
-
Save kepta/b9f9b37dd4fe74dae32ad8968f719760 to your computer and use it in GitHub Desktop.
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
function goodProm(maybePromise) { | |
return Promise.resolve(maybePromise); | |
} | |
goodProm(5).then(console.log); // 5 | |
var fivePromise = fetchMeNumber(5); // this is a promise which resolves into number 5 | |
goodProm(fivePromise).then(console.log); // 5 | |
// Notice it unwraps all the layers of promises automagically! | |
goodProm(Promise.resolve(Promise.resolve(5))).then(console.log); // 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment