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

Closure function in a loop with parameters triggering 'awkward use of new'

Expand Messages
  • saj14saj
    The following code: function testEnvironment() { for (var i = 0; i
    Message 1 of 2 , Jul 2, 2008
    View Source
    • 0 Attachment
      The following code:

      <pre>
      function testEnvironment() {

      for (var i = 0; i < 10; i++) {
      (function (i) {
      console.log('Closure with i counting');
      } (i));
      }

      }
      </pre>

      produces the warning:

      <pre>
      Error:
      Problem at line 6 character 7: Awkward use of 'new'.

      } (i));
      </pre>

      I don't know if this is a bug, or if there is something very subtle
      in JavaScript that I don't understand.
    • Douglas Crockford
      ... It has been fixed. Thank you for report it.
      Message 2 of 2 , Jul 2, 2008
      View Source
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "saj14saj" <saj14saj@...> wrote:

        > I don't know if this is a bug, or if there is something very subtle
        > in JavaScript that I don't understand.

        It has been fixed. Thank you for report it.
      Your message has been successfully submitted and would be delivered to recipients shortly.