Skip to content

Instantly share code, notes, and snippets.

@rhysyngsun
Created June 20, 2009 22:09
Show Gist options
  • Save rhysyngsun/133309 to your computer and use it in GitHub Desktop.
Save rhysyngsun/133309 to your computer and use it in GitHub Desktop.
String.prototype.namespace = function(properties) {
var ns = this.split('.'),
o = window,
i,
len;
for (i = 0,len = ns.length; i < len; i++) {
o = o[ns[i]] = o[ns[i]] || {};
}
for (prop in properties) {
o[prop] = properties[prop];
}
return o;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment