Last active
December 26, 2015 03:58
-
-
Save vvo/7089309 to your computer and use it in GitHub Desktop.
api namespace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
a solution: https://github.com/vvo/namespace-example/tree/object-create