Skip to content

Instantly share code, notes, and snippets.

@vvo
Last active December 26, 2015 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vvo/7089309 to your computer and use it in GitHub Desktop.
Save vvo/7089309 to your computer and use it in GitHub Desktop.
api namespace
How would you implement a js solution to set up an api namespace:
api.ns.method();
api.ns2.method2();
api.ns2.method3();
api.prop = 'hello';
where
ns.method and ns2.method2 can access all `api` properties/ns using `this`:
function method2() {
// this === api
//
this.ns.method();
this.method3(); // refers to ns2
this.prop; // refers to top lvl context
}
?
@vvo
Copy link
Author

vvo commented Oct 21, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment