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

940Re: Variable x was used before it was declared.

Expand Messages
  • Douglas Crockford
    Oct 1, 2009
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, Toby Maxwell-Lyte <toby.maxwelllyte@...> wrote:
      > When JSLinting there are several scenarios where we get the "Variable
      > {a} was used before it was declared. " message.
      >
      > This usually occurs when we define static constants before the constructor. E.g.
      >
      > MyClass.CONSTANT = 23;
      >
      > function MyClass () {
      > }
      >
      > MyClass.prototype.myMethod = function () {
      > }
      >
      > What is the rational behind this check?

      Declare names before they are used. Write it this way:

      function MyClass () {
      }

      MyClass.CONSTANT = 23;

      MyClass.prototype.myMethod = function () {
      };
    • Show all 9 messages in this topic