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

Re: False positive on Body of a for-in warning.

Expand Messages
  • Douglas Crockford
    ... JSLint s complaint was Expected an assignment or function call and instead saw an expression. JSLint is expecting something like for (b in a) { if
    Message 1 of 2 , Jun 29, 2010
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "aceblchboy" <aceblchboy@...> wrote:
      >
      > I've been playing with google closure compiler and experimenting with its code refactoring capabilities and one of the things I noticed that seems incompatible here is that I get the warning: The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype, when it is in fact filtered.
      >
      > example code:
      > for (b in a) {
      > a.hasOwnProperty(b) && one-line filtered for-in body code here.
      > }

      JSLint's complaint was "Expected an assignment or function call and instead saw an expression." JSLint is expecting something like

      for (b in a) {
      if (a.hasOwnProperty(b)) {
      one-line filtered for-in body code here.
      }
      }
    Your message has been successfully submitted and would be delivered to recipients shortly.