Benefits of using Higher order function that returns a function CODE
Creates several multiplier functions without using
Higher order function
function doubleMe(number) {
    return 2*number;
}
function tripleMe(number) {
    return 3*number;
}
function quadrupleMe(number) {
    return 4*number;
}
document.write(doubleMe(10));
document.write(tripleMe(10));
document.write(quadrupleMe(10));
Creates the same multiplier functions using
Higher order function
In this case we only need to create one function instead of 3 multiplier functions
function multiplier(multiply) {
    return function(number){
        return number*multiply;
    };
}

let double = multiplier(2);
let triple = multiplier(3);
let quadruple = multiplier(4);

document.write(double(10));
document.write(triple(10));
document.write(quadruple(10));
by Valeri Tandilashvili
4 years ago
JavaScript
Higher order function
1
Pro tip: use ```triple backticks around text``` to write in code fences