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

False positive errors on for loops

Expand Messages
  • sandyhead25
    Consider the following code. var a = function () { use strict ; var b = [], c = b.length, d = 0; for (; d
    Message 1 of 2 , Oct 25, 2011
    • 0 Attachment
      Consider the following code.

      var a = function () {
      "use strict";
      var b = [],
      c = b.length,
      d = 0;
      for (; d < c; d += 1) {
      return "";
      }
      };

      The point of contention is at "(; d" in the for loop. Either I am using an unapproved convention and JSLint is generating incorrect errors or I am using a valid convention and JSLint should not be generating any errors at all.

      Austin
    • Douglas Crockford
      ... It is the former. JSLint expects that either all 3 clauses are empty, or they are all used. The first clause is expected to initialize the induction
      Message 2 of 2 , Oct 25, 2011
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "sandyhead25" <austin.cheney@...> wrote:
        >
        > Consider the following code.
        >
        > var a = function () {
        > "use strict";
        > var b = [],
        > c = b.length,
        > d = 0;
        > for (; d < c; d += 1) {
        > return "";
        > }
        > };
        >
        > The point of contention is at "(; d" in the for loop. Either I am using an unapproved convention and JSLint is generating incorrect errors or I am using a valid convention and JSLint should not be generating any errors at all.


        It is the former. JSLint expects that either all 3 clauses are empty, or they are all used. The first clause is expected to initialize the induction variable.
      Your message has been successfully submitted and would be delivered to recipients shortly.