jQuery.prototype = {
constructor: jQuery,
init: function( ){
}
}
这是怎样的用法啊,我知道prototype能增加方法,但是,一般的用法不是a.prototype.add = function(){}吗?求高手指教
constructor: jQuery,
init: function( ){
}
}
这是怎样的用法啊,我知道prototype能增加方法,但是,一般的用法不是a.prototype.add = function(){}吗?求高手指教
也可以用类似jQuery.prototype的方式直接覆盖原型,你可以把prototype看做为json对象。
但直接对prototype赋值会将对象的构造函数指向Object;
所以需要显性的将prototype.constructor 设回 jQuery;
这样也有个问题就是constructor 将能被枚举。