问答详情
源自:2-2 分离构造器

Query.fn.aQuery.init {}

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

提问者:zhongping_ 2015-04-18 13:07

个回答

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

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