Skip to content

Instantly share code, notes, and snippets.

@Gaya
Created March 10, 2017 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gaya/8d8386fb5305373bdd9a07c83ef545ad to your computer and use it in GitHub Desktop.
Save Gaya/8d8386fb5305373bdd9a07c83ef545ad to your computer and use it in GitHub Desktop.
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