Use the higher-order function to change a function:
Let's look at the example that uses the higher-order function to change a function.
xxxxxxxxxx
const intArr = [3,10,25,1,7]
function changeFn(f) {
return function getArr(arr) {
let result = f(arr);
console.log("Called with", arr, ", returned", result);
return result;
};
}
changeFn(Math.min)(intArr);
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment