Skip to content

Instantly share code, notes, and snippets.

@alanerzhao
Last active December 20, 2015 14:49
Show Gist options
  • Save alanerzhao/6149922 to your computer and use it in GitHub Desktop.
Save alanerzhao/6149922 to your computer and use it in GitHub Desktop.
//namespace 方法
var MYAPP = {}
MYAPP.namespcae = function (name) {
var parts = name.split('.');
var current = MYAPP;
for(var i in parts) {
if(!current[parts[i]]) {
current[parts[i]] = {}
}
current = current[parts[i]]
}
}
//MYAPP.namespcae('event')
//MYAPP>namescpae('dom.style')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment