Hi,

In ECMAScript, function declarations are SourceElements, but not Statements. This means that they can only occur at the top level, and may not be nested inside a block.

However, browsers support function declarations as statements, and many scripts on the web seem to make use of this ability, especially after they have been minified.

Is there a spec anywhere for how functions as statements should behave?

Can they be rewritten to var + function expression, so that this:

{
    function f() { return 17 }
}

becomes this:

{
    var f = function() { return 17 }
}

When implementing non-standard features, it would be nice to do so in a standard manner :)

Best regards,

Michael

--
Print XML with Prince!
http://www.princexml.com
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to