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

newcap

Expand Messages
  • Julien Royer
    Hi, Why does JSLint use the following regexp to detect names beginning with a capital letter (newcap option)? /^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/ It
    Message 1 of 7 , Feb 4, 2010
    • 0 Attachment
      Hi,

      Why does JSLint use the following regexp to detect names beginning
      with a capital letter (newcap option)?
      /^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/

      It makes the following names valid for non-constructor functions:
      "T1", "HTML", "H$1", ...
    • Woomla
      ... I m just curious what you mean by this. How do you create objects then?
      Message 2 of 7 , Feb 9, 2010
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
        > In my practice, I completely avoid use of new.

        I'm just curious what you mean by this. How do you create objects then?
      • Douglas Crockford
        ... I use object literals and Object.create(prototype). Object.create is in ES5. It can be added to ES3 with if (!Object.create) { Object.create = function
        Message 3 of 7 , Feb 9, 2010
        • 0 Attachment
          --- In jslint_com@yahoogroups.com, "Woomla" <woomla@...> wrote:
          >
          > --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@> wrote:
          > > In my practice, I completely avoid use of new.
          >
          > I'm just curious what you mean by this. How do you create objects then?


          I use object literals and Object.create(prototype). Object.create is in ES5. It can be added to ES3 with

          if (!Object.create) {
          Object.create = function (prototype) {
          function F() {}
          F.prototype = prototype;
          return new F();
          };
          }
        Your message has been successfully submitted and would be delivered to recipients shortly.