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

Re: Require Initial Caps for constructors

Expand Messages
  • pauanyu
    ... JSLint requires constructors to have an initial capital letter. This is to prevent errors when you forget to use new , binding to the global object. Just
    Message 1 of 2 , Jul 24, 2009
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "Donavon West" <donavonwest@...> wrote:
      >
      > Take the following code sample. When I run it through JSLint with "Require Initial Caps for constructors" set (my default), I receive an "A constructor name should start with an uppercase letter" error. Is it possible for JSLint suppress this for situations like this?
      >
      > Thx,
      > Donavon
      >
      >
      > function Dog() {
      > this.whatDoesItSay = "Woof!";
      > }
      >
      > function createInstanceOf(p_object) {
      > return new p_object();
      > }
      >
      > alert( createInstanceOf(Dog).whatDoesItSay );
      >

      JSLint requires constructors to have an initial capital letter. This is to prevent errors when you forget to use "new", binding to the global object.

      Just change "p_object" to "P_object" and it should run fine.
    Your message has been successfully submitted and would be delivered to recipients shortly.