Created
October 19, 2015 20:26
-
-
Save tobynet/a2cec6ca3e453b3e30e3 to your computer and use it in GitHub Desktop.
Let's play on the Promises
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
pre#log |
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
let double = (x) => x * x | |
, plus = (x) => (y) => x + y | |
, print = (x) => { | |
document.querySelector("#log") | |
.appendChild( | |
document.createTextNode(x + "\n")); | |
return x; | |
} | |
Promise.resolve(10) | |
.then(print) | |
.then(double) | |
.then(print) | |
.then(plus(10)) | |
.then(print); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment