Re: jslint doesn't like my syntax for conditional object creation



VK wrote:
Or unless... briefly do not repeat my mistake and don't try
to restore 3rd party context by few errors. Wait until OP will post the
relevant code.

Richard Cornford wrote:
As if I would take your advice on anything.

And that's a shame because whoever doesn't take VK's advises is being
beat down publically (smile, joke, humor :-)

Go to <http://www.jslint.com/> and paste this single line of text to
validate:
if (Serious == null) {var Serious = {};}

You get these exact errors OP got:
Problem at line 1 character 16: Use '===' to compare with 'null'.

if (Serious == null) {var Serious = {};}

Problem at line 1 character 27: Var Serious was used before it was
declared.

if (Serious == null) {var Serious = {};}

Problem at line 1 character 27: Identifier 'Serious' already
declared as global

if (Serious == null) {var Serious = {};}

As I mentioned before, no one of them actually points to the real
problem (exception raised by addressing non-declared variable). JSLint
neuristic needs much more improvement on that.


The code you "restored" in your mind gives all different errors:
var Serious;
if (Serious == null) {var Serious = {};}

gives:

Problem at line 2 character 16: Use '===' to compare with 'null'.

if (Serious == null) {var Serious = {};}

Problem at line 2 character 27: Identifier 'Serious' already declared
as var*

if (Serious == null) {var Serious = {};}


That is a silly question. I know because I have spent some time
learning Javascript. I have also read and understood the source code
for JSLint and discussed the motivation for its error and warning
output with its author.

You may want to have more discussion with him after that (just don't
use the bat :-)


There is no such thing as a conditional variable declaration in javascript.

Eh?? No comments, really.

.



Relevant Pages

  • Re: new Array() vs []
    ... var x = new Array; ... Problem at line 1 character 13: Use the array literal notation. ... JSLint is a great tool with a lot of thoughts put into it, ...
    (comp.lang.javascript)
  • Re: Armenian, Sumerian, Burushaski, and Turkic languages
    ... - sort of a blank character, ... maybe it really is a Norwegian thing. ... Det var en liten gutt som gikk og græt og var så lei, ... med blanke ark og fargestifter tel. ...
    (sci.lang)
  • Which special ability? [O, YACD]
    ... [Oangband 1.1.0 Character Dump] ... a Stone of Nature Lore ... a Viscous Pink Potion of Restore Wisdom ...
    (rec.games.roguelike.angband)
  • Re: javascript compression
    ... var RingBellOnFatalError = false; ... returns a string detailing the line and char position of default ... read a character from line buffer, ... // tokens - an array of predifined tokens ...
    (microsoft.public.scripting.jscript)
  • Re: Trying to limit input ot certain numbers
    ... " part is and were in the help files I can learn about it. ... If you want one character from a string, then use the array-access notation to extract just that one character: ...
    (alt.comp.lang.borland-delphi)