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

Feature request: disable message about assignment-in-while cond

Expand Messages
  • M. Lorton
    Right now, the code var a; while (a = f()) { ... causes JSLint to complain -- which is right in many cases: you are doing an assignment when you meant to do a
    Message 1 of 2 , Jan 9, 2009
    • 0 Attachment
      Right now, the code

      var a;
      while (a = f()) {
      ...

      causes JSLint to complain -- which is right in many cases: you are
      doing an assignment when you meant to do a comparison.

      But what if you meant to do the assignment? I would like to be able
      to indicate in some way to JSLint that (Pee-Wee Herman voice) "I meant
      to do that."
    • James Clark
      I believe the standard technique works (add extra parens): while ((a = f())) { -jamie
      Message 2 of 2 , Jan 9, 2009
      • 0 Attachment
        I believe the standard technique works (add extra parens):

        while ((a = f())) {

        -jamie

        M. Lorton wrote:
        >
        >
        > Right now, the code
        >
        > var a;
        > while (a = f()) {
        > ...
        >
        > causes JSLint to complain -- which is right in many cases: you are
        > doing an assignment when you meant to do a comparison.
        >
        > But what if you meant to do the assignment? I would like to be able
        > to indicate in some way to JSLint that (Pee-Wee Herman voice) "I meant
        > to do that."
      Your message has been successfully submitted and would be delivered to recipients shortly.