Skip to content

Instantly share code, notes, and snippets.

@jbrantly
Created April 27, 2010 19:13
Show Gist options
  • Save jbrantly/381165 to your computer and use it in GitHub Desktop.
Save jbrantly/381165 to your computer and use it in GitHub Desktop.
var namespace = function(str) {
var parts = str.split('.');
var nsLevel = window;
for (var i = 0, n = parts.length; i < n; i++) {
nsLevel = nsLevel[parts[i]] = nsLevel[parts[i]] || {};
}
};
namespace('myNamespace.subNamespace');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment