jquery-2.0.3 源码分析 整体架构

关键


  var jQuery = function( selector, context ) {
    return new jQuery.fn.init();
  }

  jQuery.fn = jQuery.prototype = {

    constructor: jQuery,

    name: 'hello',

    init: function() {

      return this;

    }

  }

  jQuery.fn.init.prototype = jQuery.fn;

  var a = new jQuery();
  console.log( a.name )  //hello

扩展

jQuery.extend = jQuery.fn.extend = function() {

jQuery.extend 对jQuery本身的属性和方法进行了扩展 : 

jQuery.fn.extend 对jQuery.fn的属性和方法进行了扩展 : 

转载:

by Aaron:http://www.cnblogs.com/aaronjs/p/3278578.html

原文地址:https://www.cnblogs.com/liuyingde/p/7648691.html