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

Re: Namespace notation

Expand Messages
  • pauanyu
    I like this syntax, personally: var MYNS = MYNS || {}; You can also use an if for more accurate checks: var MYNS; if (!(MYNS instanceof Object)) { MYNS = {};
    Message 1 of 2 , Mar 11, 2010
    • 0 Attachment
      I like this syntax, personally:

      var MYNS = MYNS || {};

      You can also use an "if" for more accurate checks:

      var MYNS;
      if (!(MYNS instanceof Object)) {
      MYNS = {};
      }

      --- In jslint_com@yahoogroups.com, "martijnbeulens" <mbeulens@...> wrote:
      >
      > Hi everybody,
      >
      > I was wondering how to define my root namespace in "strict format"
      >
      > Normally i use the following code:
      >
      > /*global YAHOO, MYNS */
      > if (!this.MYNS) {
      > this.MYNS = {};
      > }
      >
      > Now i did this
      > /*global YAHOO, MYNS */
      > "use strict";
      > if (!this.MYNS) {
      > this.MYNS = {};
      > }
      >
      > but JSLINT gives me:
      > Problem at line 2 character 6: Strict violation;
      >
      > Does anybody know what the correct way is?
      >
      > Only way i could think of is just
      > /*global YAHOO, MYNS */
      > var MYNS = {};
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.