Query.fn.aQuery.init {}

来源:2-2 分离构造器

zhongping_

2015-04-18 13:07

ajQuery.fn = ajQuery.prototype = {    name: 'aaron',    init: function() {        console.log(this)    },    constructor: ajQuery } 为什么输入的是 aQuery.fn.aQuery.init {} 如果去掉 aQuery.fn=  就是 aQuery.init ?

写回答 关注

1回答

  • tonyfang
    2016-01-21 15:37:34

    ajQuery.fn和ajQuery.prototype指向同一个原型对象,fn比prototype省略了7个字母,使用次数越多这样做的好处就体现出来了。aQuery.fn.aQuery.init {}这样的写法是错误的,aQuery.fn.init {}和ajQuery.prototype.init {}是一回事


jQuery源码解析(架构与依赖模块)

由浅入深地剖析jQuery库的设计与实现,揭开框架背后的秘密

84041 学习 · 290 问题

查看课程