Hacker Newsnew | comments | show | ask | jobs | submit login

JavaScript 1.7 already supports a very similar module pattern. For example:

    myModule: {
      // don't do anything if myModule is already included
      if (myModule) break myModule;
      
      let this_is_private = ...;
      var myModule = ...;
      // myModule is public and won't pollute the
      // global NS if it isn't included globally.
    }



Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: