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 に答える