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

3183Re: [jslint] Re: jslint error: "Bad for in variable 'header'.?

Expand Messages
  • Lindsay John Lawrence
    Mar 19, 2013
      I am sorry about that. I needed another pair of eyes....

      On further inspection... the actual code was something like:

      /*global doDoh */
      (function doh (headers)  {
        "use strict";
        var header; 
        var noop = function () {};
        doDoh (function () {
          for (header in headers) {

             if (headers.hasOwnProperty(header)) {
                  noop(); 
                }
              }  
          });
      }());


      So, while it ran, it failed jslint due to where I had 'header' declared.  I like my code to pass jslint. In this case I was momentarily blind to the inner function.

      Thank you.



      ________________________________
      From: douglascrockford <douglas@...>
      To: jslint_com@yahoogroups.com
      Sent: Tuesday, March 19, 2013 4:53 PM
      Subject: [jslint] Re: jslint error: "Bad for in variable 'header'.?


       
      --- In jslint_com@yahoogroups.com, Lindsay John Lawrence <thinknlive@...> wrote:
      >
      > I am currently getting the following error in JSLint and don't understand why.
      > ----------------------------------------------------------
      > Bad for in variable 'header'.
      > ----------------------------------------------------------
      >
      > I am iterating over object {} properties (not an array), am using hasOwnPropery() and both header and headers are declared in the relevant scope.
      >
      > Can someone tell me why? I read through the '
      >
      > Sample Code:
      >
      >         var header;
      >         var headers = {...};  
      > for (header in headers) {
      >      if (headers.hasOwnProperty(header)) {
      >          .....
      >      }
      > }

      It works for me.




      [Non-text portions of this message have been removed]
    • Show all 13 messages in this topic