Skip to content

Instantly share code, notes, and snippets.

@tarmann
Created May 21, 2013 19:52
JavaScript: Underscore Mixin for Namespacing
_.mixin({
namespace: function (path) {
var objects = path.split('.'),
namespace = window;
_.each(objects, function(obj, i){
namespace[obj] = namespace[obj] || {};
namespace = namespace[obj]
});
return namespace;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment