Reputation: 133
I have a lot window variables in my project, some of them are just values, some of them are functions, whats the best practice for creating one global namespace for all of them, anf how should i use it?
Upvotes: 0
Views: 50
Reputation: 140
There are different ways to achieve this, best practice would be using a module system like RequireJS or CommonJS. Alternatively you could follow the generic module pattern. The way you use modules may be different for your environment, node.js for example uses the CommonJS module format, and NPM for package (module) management. In the browser its much more flexible, usually it comes down to including the appropriate script tags in your HTML document.
Upvotes: 1