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

38Re: Using the singleton pattern results in JSlint error

Expand Messages
  • Douglas Crockford
    May 11, 2008
    • 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.
    • Show all 2 messages in this topic