In the simple, 2 layer currying
example below the word dog is passed into the y argument.
"use strict";
function layer2(x) {
return function(y) {
return console.log(x, y);
}
}
var layer1 = layer2('cat');
layer1('dog');
I know it works this way and I can reliably reproduce this. However I can't understand the mechanics of why this works. If I made a 100 layer example layer 1 would be the innermost function and the pattern would work outwards from that point. What piece of basic mechanics causes this? Thanks so much for any input!