Nested functions may be defined only at the top level of the function within which they are nested. That
is, they may not be defined within statement blocks, such as the body of an if statement or while
loop.[*] Note that this restriction applies only to functions defined with the function statement . Function
literal expressions, which are described in the next section, may appear anywhere.
[*] Different implementations of JavaScript may be more relaxed about function definitions than the standard requires. For example,
Netscape's implementation of JavaScript 1.5 allows "conditional function definitions" that appear within if statements.