I need to code a module pattern instantiated in a window property. What would be the best way of doing that?
var widget = (function(){
}());
I need to code a module pattern instantiated in a window property. What would be the best way of doing that?
var widget = (function(){
}());
The new best practice in JS world is to use UMD or es6 modules with rollup library and/or babel.
Short answer to your question
(function(global){
global.widgetName = {};
}(this));