jquery中的原型链

var jQuery = function(global, factory) {

    return new jQuery.fn.init();

}


jQuery.fn = jQuery.prototype = {

    constructor: jQuery,

    init: function() {

        this.jquery = 3;

        return this;

    },

    each: function() {

        console.log('each');

        return this;

    }

}


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


// init构造函数

jQuery().each().each()

上面是一段jQuery源码,我的问题是为什么代码最后一行的第二个each函数还能够执行

长风秋雁
浏览 432回答 1
1回答

开心每一天1111

因为你return的是this,别说两个了,10个也可以
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript