Loading ...
Sorry, an error occurred while loading the content.

Re: [jslint] !== operator and assignment in a while statement

Expand Messages
  • Michael Lorton
    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
    Message 1 of 3 , May 25, 2009
    • 0 Attachment
      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.

      M.




      ________________________________
      From: kelu2 <kelu2@...>
      To: jslint_com@yahoogroups.com
      Sent: Monday, May 25, 2009 6:53:16 AM
      Subject: [jslint] !== operator and assignment in a while statement

      Hi,

      I just ran some code in JSlint and got various messages (as expected):

      1. Operators:
      I got:
      Use '!==' to compare with 'null' (or false)
      and
      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:
      I got:
      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.

      Thanks,

      Luc.



      ------------------------------------

      Yahoo! Groups Links



      [Non-text portions of this message have been removed]
    • pauanyu
      ... Both of these cases (and more) are explained here: http://www.jslint.com/lint.html
      Message 2 of 3 , May 25, 2009
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "kelu2" <kelu2@...> wrote:
        >
        > How do these operators behave compared to '==' and '!='? It is actually the first time I encounter them.
        >
        > while (character = this.get_next_character())
        >

        Both of these cases (and more) are explained here:

        http://www.jslint.com/lint.html
      Your message has been successfully submitted and would be delivered to recipients shortly.