Skip to content

Instantly share code, notes, and snippets.

@piotrmurach
Created November 3, 2011 22:59
Show Gist options
  • Select an option

  • Save piotrmurach/1338196 to your computer and use it in GitHub Desktop.

Select an option

Save piotrmurach/1338196 to your computer and use it in GitHub Desktop.
Attaching variables to global namespace
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