What should be the output of the following code?

(function(){

try {
 throw "hi";
} catch (e) {
 var e = "ho";
 var o = "hu";
 var u;
 console.log(e);
}
console.log(e,u,o);

}());

It seems clear that the first console.log should output 'ho'.
Implementations seem to disagree on the second console.log, though.

From my current understanding of the spec, I expected:

   undefined undefined 'hu'

which I consider unfortunate; especially the first 'undefined'
was intended to demonstrate the bad effects of separating declaration from initialization while treating catch and function differently, in terms of scoping.

node, opera: undefined undefined 'hu'

firefox 12 complains: 'e is not defined'

ie 9 outputs: houndefinedhu

It looks as if firefox misses the hoisted declaration of 'e'
(it doesn't complain about 'u', only about 'e') while ie9 somehow merges the declaration and the catch parameter.

Claus

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to