Re: [jslint] !== operator and assignment in a while statement
- 1. Triple-equals is the identity operator: do these two expressions refer to the same object or the same value. Double-equals means, do these two expressions produce results that can be coerced into some semblance of equality. The problems with double-equals are grievous and manifold (one of the worse, in my opinion, is that it isn't reflexive: there are some expressions a and b such that a == b, but ! (b == a) ).
2. Write while ( (character = this.get_next_character())) and the warning goes away.
From: kelu2 <kelu2@...>
Sent: Monday, May 25, 2009 6:53:16 AM
Subject: [jslint] !== operator and assignment in a while statement
I just ran some code in JSlint and got various messages (as expected):
Use '!==' to compare with 'null' (or false)
Use '===' to compare with 'null'.
How do these operators behave compared to '==' and '!='? It is actually the first time I encounter them.
2. Conditional expressions:
Problem at line 250 character 26: Expected a conditional expression and instead saw an assignment.
while (character = this.get_next_character())
I do not think this is a problem as this.get_next_character() will return false at some point and other values for character evaluate to true, which is desired behaviour.
Yahoo! Groups Links
[Non-text portions of this message have been removed]
- --- In email@example.com, "kelu2" <kelu2@...> wrote:
>Both of these cases (and more) are explained here:
> How do these operators behave compared to '==' and '!='? It is actually the first time I encounter them.
> while (character = this.get_next_character())