Skip to content

Instantly share code, notes, and snippets.

@roundcorners
Created January 24, 2012 21:06
Show Gist options
  • Save roundcorners/1672703 to your computer and use it in GitHub Desktop.
Save roundcorners/1672703 to your computer and use it in GitHub Desktop.
Namespacing with a object literal
// Top-level namespace
var MyNamespace = {};
// Adding properties to my namespace
MyNamespace.application = {};
// OR
MyNamespace.['application'] = {};
// Adding a method to my namespace
MyNamespace.application.myFunc = function (a) {
....
return a;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment