I read this snippet in the definitive guide:
function not(f)
{
return function()
{
var result=f.apply(this,arguments);
return !result;
}
}
What I can't understand is, since this function f is in the closure, it's this is already this, why wouldn't this snippet just directly use var result=f(arguments);?
I even read some calls with undefined/null as the first parameter which I think can completely be replaced with direct call:
...
while(i>len)
{
if(i in a)
accumulator=f.call(undefined,accumulator,a[i],i,a);
i++;
}
...
Why did the author use call() but not direct call? are there any difference between direct function call and call() with undefined as it's first parameter?