I was reading through Eloquent JavaScript, when I came across this in chapter 5. :
you can have functions that create new functions.
function greaterThan(n) { return function(m) { return m > n; }; } var greaterThan10 = greaterThan(10);And you can have functions that change other functions.
function noisy(f) { return function(arg) { console.log("calling with", arg); var val = f(arg); console.log("called with", arg, "- got", val); return val; }; } noisy(Boolean)(0); //->calling with 0 //->called with 0 - got false
My questions are:
- How are the above two examples different?
- How does noisy change Boolean?