Note that negate both take a function as an argument and return a function. The returned function will call the argument function, negating the return value. So isNotNaN is a function. When it is called, it will call the function originally passed to negate , in this case isNaN . Everything you call isNotNaN with will be passed to isNaN .
Essentially, you are setting up a function using another function. This might be easier to see with a simpler (without argument function):
function addX(x) { return function(y) { return x+y; }; } var add2 = addX(2); console.log(add2(2));
Now take one more step and imagine that you passed the function to addX instead of the value.
By the way, this is called currying .
source share