Object.prototype.isPrototypeOf()【プロトタイプチェーン存在有無】メソッド

メモ

  • 別オブジェクトのプロトタイプチェーンに存在するか否か

構文

  • prototype.isPrototypeOf ( V )

  • V:オブジェクト

プロトタイプチェーン存在有無 (true:有り / false:無し)

function F1() {};
function F2() {};
function F3() {};
function F4() {};
F2.prototype = new F1();
var f2 = new F2();
F3.prototype = new F2();
var f3 = new F3();
var f4 = new F4();
console.log(F1.prototype.isPrototypeOf(f2));  // true
console.log(F1.prototype.isPrototypeOf(f3));  // true
console.log(F1.prototype.isPrototypeOf(f4));  // false

関連