July 2013
Intermediate to advanced
382 pages
6h 56m
English
Functions in JavaScript are actually data. This is an important concept that we'll need later on. This means that you can create a function and assign it to a variable:
var f = function () {
return 1;
};This way of defining a function is sometimes referred to as function literal notation.
The part function () { return 1; } is a
function expression. A function expression can optionally have a name, in which case it becomes a named function expression
(NFE). So, this is also allowed, although rarely seen in practice (and causes IE to mistakenly create two variables in the enclosing scope: f and myFunc):
var f = function myFunc() {
return 1;
};As you can see, there's no difference between a named function expression and a function ...
Read now
Unlock full access