jquery源码--jquery对象

(function( window, undefined ) {
   // 构造 jQuery 对象
22  var jQuery = (function() {
25    var jQuery = function( selector, context ) {
27      return new jQuery.fn.init( selector, context, root jQuery );
28    },
    // 一堆局部变量声明
97      jQuery.fn = jQuery.prototype = {
98        constructor: jQuery,
99        init: function( selector, context, rootjQuery ) { ... },
          // 一堆原型属性和方法
319      };
322    jQuery.fn.init.prototype = jQuery.fn;
324    jQuery.extend = jQuery.fn.extend = function() { ... };
388    jQuery.extend({
      // 一堆静态属性和方法
892    });
955    return jQuery;
957 })();
  // 省略其他模块的代码
9246  window.jQuery = window.$ = jQuery;
9266 })( window );

1.jquery对象为jquery.fn.init new的实例,也就是说jquery的构造函数是jquery.fin.init()。这个地方比较凌乱。。再研究

2.据说jquery.prototype赋值为jquery.fn是为了简短字母量。

 

 

 

另:

文章算是《jquery 技术内幕》的读书笔记,http://book.douban.com/subject/25823709/

posted @ 2014-08-11 19:03  前端小蜗牛  阅读(164)  评论(0编辑  收藏  举报