[thelist] Javascript: Assignment/Comparision (WAS altering BG color etc. )

Hershel Robinson hershelr at netvision.net.il
Wed Nov 12 05:15:30 CST 2003


> if (i = 0)
>
> is perfectly valid syntactically.  It just doesn't do what he
> intended,
> which is what makes bugs of this type so annoying to ferret
> out.

I stand corrected. The above line is valid. I thought I had tried this in
the past and it had failed, but I see now (empirically) that it does work.

> It will
> always be true.

Well, in reality it will always be false because it returns zero.

> I agree with the original poster that it is odd that this crashed his
> browser.

I do not think that line in and of itself crashed his browser. These lines:

var i=0
if (i=0) alert(0)
if (i=1) alert(1)

do not crash my browser (Win 2K IE6). I see one alert with the text '1' and
that's it.

Hershel



More information about the thelist mailing list