Skip to content

Instantly share code, notes, and snippets.

@RStankov
Created March 11, 2009 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RStankov/77625 to your computer and use it in GitHub Desktop.
Save RStankov/77625 to your computer and use it in GitHub Desktop.
String.prototype.namespace = function(objects, scope){
scope = scope || window;
this.split('.').each(function(name){
if (Object.isUndefined(scope[name])) scope[name] = {};
scope = scope[name];
});
if (objects) Object.extent(scope, objects);
return scope;
}
'com.pixeldepo.some.package'.namespace();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment