On Tuesday, March 17, 2015 at 3:26:52 PM UTC+1, Jason Orendorff wrote:
> It's not a bug, but it's a known ...situation.
>
> Function statements inside blocks are not a standard feature. They've had
> different behavior in different JS engines basically forever, and the last
> time we tried to change the behavior we gave up because it broke web sites.
>
> If you tried that in strict mode code, it would be a SyntaxError. Programs
> shouldn't use function statements except (a) at toplevel, like your second
> example; (b) immediately inside the body of a function.
>
> -j
I see and the cases below corrects you. The code below also works.
function q() {
var client1 = {on:function(){}};
client1.on('close', onclose);
function onclose() {
console.log('dummy2');
}
}
q();
and the below one fails;
function q(){
if (t == 1) {
var client1 = {
on: function () {
}
};
client1.on('close', onclose);
function onclose() {
console.log('dummy2');
}
}
}
q();
Still, considering the today's JavaScript usage, and this one is already
handled by an other browser(s), it feels a bit inconsistent. I mean, it fails
even though there is no 'use strict' in place.
_______________________________________________
dev-tech-js-engine-internals mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals