只要我将下面的代码添加到我的html页面,我就会得到:
Uncaught TypeError: Object function (constrname) {
if(this.constructor.name===constrname){
return true;
}
return false;
} has no method 'exec'
这是导致错误的原型:
Object.prototype.isInstanceOf=function(constrname) {
if(this.constructor.name===constrname){
return true;
}
return false;
};
添加原型似乎是破解jQuery。
在将新原型定义为Object类型时,我可以排除某些类型。例如,exclude:jQuery type,...
我尝试了以下代码,但这是徒劳的:
Object.prototype.isInstanceOf=function(constrname) {
if(!(this instanceof jQuery)){
//write here code
}
}
答案 0 :(得分:0)
不,这是不可能的。原型继承的全部要点是原型上的对象由每个后代继承。你不能删除它们。