Skip to content

Instantly share code, notes, and snippets.

@DavidRogersDev
Created August 24, 2022 02:18
Show Gist options
  • Save DavidRogersDev/d4ea3059339befd864e408b135a13e5e to your computer and use it in GitHub Desktop.
Save DavidRogersDev/d4ea3059339befd864e408b135a13e5e to your computer and use it in GitHub Desktop.
CreateNamespace is a Function which can be used to Namespace your code if you are working with an old codebase.
// function from the old days before Modules. Was very handy if you wanted to namespace your code.
if (!window.createNamespace) {
window.createNamespace = function (name, separator, container) {
var o = container || window;
name.split(separator || '.').forEach(function (x) {
o = o[x] = o[x] || {};
});
return o;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment