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

Re: Using the singleton pattern results in JSlint error

Expand Messages
  • Douglas Crockford
    ... Drop the unnecessary new operator, then it will be correct.
    Message 1 of 2 , May 11 6:07 AM
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "klemen.slavic" <krof.drakula@...>
      wrote:
      >
      > When constructing a singleton in JS using an anonymous constructor,
      > JSlint returns a "Weird construction" error. Here's the code:
      >
      > /*globals A*/
      > A = new function () {
      > this.hello = "world";
      > }();
      >
      > Is there a way for JSlint to detect and ignore such constructs as valid
      > singletons?

      Drop the unnecessary new operator, then it will be correct.
    Your message has been successfully submitted and would be delivered to recipients shortly.