Re: jslint doesn't like my syntax for conditional object creation
- From: "VK" <schools_ring@xxxxxxxxx>
- Date: 23 May 2006 05:30:37 -0700
Richard Cornford wrote:
VariableDeclaration productions
are processed during 'variable instantiation' (ECMA 262, 3rd ed.
Section 10.1.3) to create properties of the Variable object, prior to
the execution of code for the execution context. So the creation of
such properties of the Variable object cannot be influenced by control
flow inside the code as it has not been executed at the point of
'variable instantiation'.
OK, I admit you got me on this one - I was wrong (and ECMA specs amused
me once again).
For me the "variable declaration" is strictly like:
var a = null;
var b = '';
var ...
....
// program flow
....
and that was the point I was arguing (that the variable Serious was not
explicetly pre-declared). It did not cross my mind of this hack with
the parser fetching all var operators and pre-declaring them.
So presuming that
if (Serious == null) { var Serious = {}; }
is used outside of any function, this trick does work and it doesn't
lead to the exception. (Within a function such check is useless as
local Serious will be always here with value undefined).
I guess we can adjust the mutual score (your var operator pre-fetching
against my script tag usage :-)
But why did you decide to account this trick in the JSLint? I thought
it was supposed to be a code validator and cleaner, not a curiosity
store? Why did you decide to teach your users that if they are smart
and careful enough, they can avoid pre-declaring variables in their
code?
.
- Follow-Ups:
- Re: jslint doesn't like my syntax for conditional object creation
- From: Richard Cornford
- Re: jslint doesn't like my syntax for conditional object creation
- References:
- jslint doesn't like my syntax for conditional object creation
- From: petermichaux
- Re: jslint doesn't like my syntax for conditional object creation
- From: VK
- Re: jslint doesn't like my syntax for conditional object creation
- From: Richard Cornford
- Re: jslint doesn't like my syntax for conditional object creation
- From: VK
- Re: jslint doesn't like my syntax for conditional object creation
- From: Richard Cornford
- Re: jslint doesn't like my syntax for conditional object creation
- From: VK
- Re: jslint doesn't like my syntax for conditional object creation
- From: Richard Cornford
- Re: jslint doesn't like my syntax for conditional object creation
- From: VK
- Re: jslint doesn't like my syntax for conditional object creation
- From: Richard Cornford
- jslint doesn't like my syntax for conditional object creation
- Prev by Date: Re: jslint doesn't like my syntax for conditional object creation
- Next by Date: Re: fun with Venkman, G. Suggest, Keystrokes
- Previous by thread: Re: jslint doesn't like my syntax for conditional object creation
- Next by thread: Re: jslint doesn't like my syntax for conditional object creation
- Index(es):
Relevant Pages
|