jquery源码理解

jquery的闭包结构

function(window,undefined){
    })(window);

使用立即执行函数构造的闭包,不污染全局作用域。在对外暴露$和jquery这两个变量给外界。

jquery无new构造

jquery.fn.init.prototype = jquery.fn;

$("")实例化方法,调用的是 return new jQuery.fn.init(selector,context,rootjQuery)。

jquery.fn.init()的prototype设置为jQuery.fn,构造出来的原型对象是jQuery.fn,构造出来的方法能够访问到jQuery.fn上的所有原型方法。

 

posted @ 2018-03-16 10:18  bounce  阅读(156)  评论(1编辑  收藏  举报