Skip to content

Instantly share code, notes, and snippets.

@Gaya
Created March 10, 2017 11:33
Show Gist options
  • Select an option

  • Save Gaya/8d8386fb5305373bdd9a07c83ef545ad to your computer and use it in GitHub Desktop.

Select an option

Save Gaya/8d8386fb5305373bdd9a07c83ef545ad to your computer and use it in GitHub Desktop.

Revisions

  1. Gaya created this gist Mar 10, 2017.
    31 changes: 31 additions & 0 deletions vince.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    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']
    })