Design patterns javascript模块模式中未定义变量的意义是什么

Design patterns javascript模块模式中未定义变量的意义是什么,design-patterns,javascript,commonjs,Design Patterns,Javascript,Commonjs,我遇到了下面的javascript模块模式,并且非常喜欢它,但是,为什么在参数中使用undefined (function(window, document, undefined){ 'use strict'; var MyWidget = function(){ if (!(this instanceof MyWidget)) { var test = new MyWidget(); return test.

我遇到了下面的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);  

未定义的
在某些浏览器中可以被覆盖。这通过将
undefined
重新定义为不存在的参数值来解决您范围内的问题。

在ECMAScript 3中,开发人员有权将undefined关键字用作变量,即它是可变的。所以如果我要写

undefined = true;
未定义的值将是真的,它将失去其真正的意义。 在上述场景中,我们传递的是窗口对象、文档对象,并且没有第三个参数。这意味着在
函数(window,document,undefined)
中,未定义的变量实际上是未定义的,因为我们没有向它传递任何参数


根据ECMAScript5,这个未定义的属性不再是可变的

为什么传入窗口和文档??它们不总是可访问的吗?