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

glovar

Expand Messages
  • Douglas Crockford
    I have added a glovar option. When glovar: true, then var cannot be used to declare global variables. Fiann O Hagan convinced me that many programmers have a
    Message 1 of 2 , Apr 8 4:31 PM
    • 0 Attachment
      I have added a glovar option. When glovar: true, then var cannot be
      used to declare global variables.

      Fiann O'Hagan convinced me that many programmers have a reasonable
      expectation that top level var scopes to the compilation unit, like
      C's static. It doesn't, and unmet expectations can induce bugs.
      Further, var at the top level in implemented inconsistently, so

      var foo = this.foo || {};

      does not do what you would expect on IE7.

      JSLint will give the best results if you use the /*global*/ comment to
      declare your globals.

      /*global foo*/
    • Douglas Crockford
      I have removed the glovar option. It contracts a feature that might appear in a future edition of the language.
      Message 2 of 2 , Jul 24, 2008
      • 0 Attachment
        I have removed the glovar option. It contracts a feature that might
        appear in a future edition of the language.
      Your message has been successfully submitted and would be delivered to recipients shortly.