(function(global, factory) {
factory(global);
}(typeof window !== "undefined" ? window : this, function(window, noGlobal) {
var jQuery = function( selector, context ) {
return new jQuery.fn.init( selector, context );
(function(global, factory) { factory(global); }(typeof window !== "undefined" ? window : this, function(window, noGlobal) { var jQuery = function( selector, context ) { return new jQuery.fn.init( selector, context );等价于(function(global) { var factory=function(global, undenfined) { var jQuery = function( selector, context ) { return new jQuery.fn.init( selector, context ); } }})(typeof window !== "undefined" ? window : this); // 其实这一部分是用来判断jQ运行环境的,第一运行环境是node.js类似CommonJS和CommonJ,第二个环境是window,就是客户端,(浏览器)
里面说过:(function(global, factory) {
factory(global);
}(typeof window !== "undefined" ? window : this, function(window, noGlobal) {
var jQuery = function( selector, context ) {
return new jQuery.fn.init( selector, context );等价于
(function(global) {
var factory=function(global, undenfined) {
var jQuery = function( selector, context ) {
return new jQuery.fn.init( selector, context );
}
}
})(typeof window !== "undefined" ? window : this);
factory参数传入的是个function,就是后面括号里的function(window, noGlobal) window=global,noglobal可看作undenfined未定义