On Mon, 07 Feb 2011 22:18:02 +0100, DaveC <[email protected]>
wrote:
I think it worth a further nod wrt function statements inside of a
block statement.
ECMAScript allows syntactic extensions, one such extension is to allow
function statements inside of a block statement currently Mozilla is
the only vendor (*I think*) that has added this extension - so I would
advise against it's use as the behaviour it will inconsistent across
browsers.
Most JS engines have added *some* extension that allows you to write
if (false) {
function bar() {}
}
What it *means* differs, though.
A simple test like:
function test() {
if (false) {
function bar() { return true;}
}
return typeof bar;
}
alert(test())
shows that Firefox returns "undefined" (the function isn't defined), and
everybody
else returns "function" (the function declaration is hoisted).
/L
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]