4 ms·
Of course, the logical extension is making it generic across functions: function math(input_func){ return function(first_input){ return
by quanticle 16y ago
Of course, the logical extension is making it generic across functions:
function math(input_func){
return function(first_input){
return function(second_input){
return input_func(first_input, second_input)
}
}
}
function add(a, b){
return a + b;
}
function subtract(a, b){
return a - b;
}
alert math(add)(4)(5);
alert math(subtract)(4)(5);
Hooray for lexical closures!