<分区>
我遇到了以下javascript模块模式并且非常喜欢它,但是,为什么在参数中使用undefined
?
(function(window, document, undefined){
'use strict';
var MyWidget = function(){
if (!(this instanceof MyWidget)) {
var test = new MyWidget();
return test.init.call(test, Array.prototype.slice.call(arguments));
}
var firstPrivateVar = 'aa',
secondPrivateVar = 'bb';
this.init = function(options){
console.log('MyWidget.init', options);
return true;
};
this.setStuff = function(){
};
};
window.MyWidget = MyWidget;
})(window, document);