Skip to content

Instantly share code, notes, and snippets.

@MatteoOreficeIT
Last active November 30, 2017 10:47
Show Gist options
  • Save MatteoOreficeIT/ac050649ccc512ca3e2c45ad9483b837 to your computer and use it in GitHub Desktop.
Save MatteoOreficeIT/ac050649ccc512ca3e2c45ad9483b837 to your computer and use it in GitHub Desktop.
Short function to create namespaces in Javascript for recent browsers ( depends on jQuery and Array.prototype.reduce )
$.each([
'author.package1',
'author.package2.subpackage1',
'author.package3.subpackage4',
'author.package3.subpackage4.subpackage5',
],function(i,f){f.split('.').reduce(function(n,c){return n[c]||(n[c]={});},g)});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment