Created
November 3, 2011 22:59
-
-
Save piotrmurach/1338196 to your computer and use it in GitHub Desktop.
Attaching variables to global namespace
This file contains hidden or 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
| This will declare some 'foo' function in the global namespace, whatever it happens to be | |
| root = exports ? this | |
| root.foo = -> 'Hello World' | |
| Example of creating namespaced variables | |
| class Storage | |
| constructor: (root) -> | |
| if typeof(exports) !== 'undefined' | |
| Storage = exports | |
| else | |
| Storage = root.Storage = {} | |
| class Storage.Model | |
| add: -> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment