August 2016
Intermediate to advanced
635 pages
14h 5m
English
What is the difference between these three statements?
function foo(n){ return n; }
var foo = function(n){ return n; };
var foo = new Function('n', 'return n');At first glance, they're merely different ways to write the same function. But there's a little more going on here. And if we're to take full advantage of functions in JavaScript in order to manipulate them into a functional programming style, then we'd better be able to get this right. If there is a better way to do something in computer programming, then that one way should be the only way.
Function declarations, sometimes called function statements, define a function by using the function ...