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

Re: Possible bug in reporting 'Bad for in variable'

Expand Messages
  • Douglas Crockford
    ... JSLint expects that the induction variable is local to the function containing the loop.
    Message 1 of 8 , Aug 22 3:00 PM
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "pierremartineau" <pierrem@...> wrote:
      > I believe this is a similar problem:
      >
      > with these options:
      > /*jslint es5: true, indent: 2 */
      >
      > JSLint objects:
      > "Bad for in variable 'a'."
      >
      > on this code:
      >
      > var a, b = {}, test;
      > test = function () {
      > 'use strict';
      > for (a in b) {
      > if (b.hasOwnProperty(a)) {
      > // do anything
      > return true;
      > }
      > }
      > };
      >
      > but not on this code:
      >
      > var a, b = {}, test;
      > test = function () {
      > 'use strict';
      > var a;
      > for (a in b) {
      > if (b.hasOwnProperty(a)) {
      > // do anything
      > return true;
      > }
      > }
      > };

      JSLint expects that the induction variable is local to the function containing the loop.
    Your message has been successfully submitted and would be delivered to recipients shortly.