if(a) {
 function b(){ }
}

A block can contain statements. A statement can't start with the
function keyword.

Mozilla's Core JavaScript guide explains that of |b| should be
evaluated as a functionExpression, but this isn't right.
Source:
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Functions#Conditionally_defining_a_function

What should the above code do?

Should it be:

if(a) {
 (function b(){ });
}

SHould it be a function declaration, just like a variable statement?

if(a) {
 var b;
}

Spidermonkey treats |b| as a function declaration as a statement (example).

No imlementations I know throw a SyntaxError; instead, the behavior is
implementation-specific.

Garrett
_______________________________________________
Es4-discuss mailing list
Es4-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es4-discuss

Reply via email to