0

只要将以下代码添加到我的 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 类型定义新原型时,我可以排除某些类型吗?例如,排除:jQuery 类型,...

我尝试了以下代码,但它是徒劳的:

Object.prototype.isInstanceOf=function(constrname) {
      if(!(this instanceof jQuery)){
              //write here code
      }
}
4

1 回答 1

0

不,这是不可能的。原型继承的全部意义在于原型上的对象由每个后代继承。您无法删除它们。

于 2013-07-23T15:45:46.010 回答