Re: [jslint] Re: catch (e) ... 'e' is already defined !?!
> On Wed, Aug 11, 2010 at 11:06 AM, Alexandre Morgaut <morgaut@...>wrote:
In your original message, catch(error) generates multiple definitions in the
routine's scope (at least in IE).
var a = 1;
var a = 2;
The second 'var a' is the same as the first one, 'func1(true)' will display
'2' and you'll also have a 'b' variable declared at the end of the routine.
This is why we have ugly code for handling events in JS, because IE doesn't
send the parent event on onclick for example:
if (!evt) var evt = window.event; // just for IE, isn't that ugly ?
I also saw terrible code, where people didn't use the var keyword:
for(i = 0;i<10;++i) // yes, this variable is global !!!
I found these bugs when dumping the global variables.
On Wed, Aug 11, 2010 at 11:06 AM, Alexandre Morgaut <morgaut@...>wrote:
> Well it shouldn't
> On which browser did you test it ?
> On Firefox
> - this generate a ReferenceError: "error is not defined"
> On Safari:
> - this generate also a ReferenceError: Can't find variable: error
> which is good
You are nit-picking.
The example boyopeg has provided is probably not the best one, since the
behaviour is different from a browser to another.
But anyway, we are all trying to write cross-browser code, so we ultimately
need to consider IE's limitations.
[Non-text portions of this message have been removed]
- Hi Jean-Charles,
You are perfectly right when you say that there is no specific scope in conditional blocks
- the global scope
- the function scope
- the with scope
- & the catch scope
"with" creates a specific scope in which all properties of an object are directly accessible... It highly discouraged to use it...
the "catch" block requires an "identifier" set as a parameter for a function, create an object in matching to this exception "identifier" and remove it at the and of the catch block
Maybe Douglas would have explained it another way but the idea is there
So my surprise was to see that some User-Agent didn't implement this ECMAScript specificity as expected when ECMAScript level 3 exists from so far away
So please Microsoft.. update JScript... Do IE8 and IE9 behave that quirky way too ?