Created
October 23, 2012 12:51
-
-
Save bergquist/3938571 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function namespace(namespaceString) { | |
var parts = namespaceString.split('.'), | |
parent = window, | |
currentPart = ''; | |
for (var i = 0, length = parts.length; i < length; i++) { | |
currentPart = parts[i]; | |
parent[currentPart] = parent[currentPart] || {}; | |
parent = parent[currentPart]; | |
} | |
return parent; | |
} | |
(function(Thing) { | |
//Thing is never null | |
})(namespace('Company.Namespace.Something.Thing')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment