Skip to content

Instantly share code, notes, and snippets.

@alexbeletsky
Created September 3, 2012 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexbeletsky/3607835 to your computer and use it in GitHub Desktop.
Save alexbeletsky/3607835 to your computer and use it in GitHub Desktop.
JavaScript namespace
namespace = (function (global) {
return function (namespace) {
var splitted = namespace.split(".");
return _.reduce(splitted, function(prev, next) {
if (!prev[next]) prev[next] = { };
return prev[next];
}, global);
};
})(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment