Created
March 10, 2017 11:33
-
-
Save Gaya/8d8386fb5305373bdd9a07c83ef545ad 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 add(thing) { | |
// dit krijg 'eng' van residentEvil(); | |
// maak alvast een functie die later in then() aangeroepen wordt | |
return function(list) { | |
// list = ['leuk'] | |
return list.concat([thing]); | |
} | |
} | |
function residentEvil() { | |
return 'eng'; | |
} | |
function gamen() { | |
return new Promise((resolve) => { | |
resolve(['leuk']); | |
}); | |
} | |
gamen() // resolved ['leuk'] | |
.then(function (dingen) { | |
const functieDieResidentEvilDoet = add(residentEvil()); | |
return functieDieResidentEvilDoet(dingen); | |
}) | |
// zelfde als: | |
//.then(add(residentEvil())) | |
.then((dingen) => { | |
// dingen = ['leuk', 'eng'] | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment