JS: Object.prototype.isPrototypeOf
objA.isPrototypeOf(objB)
-
- Return
true
if objA is in Prototype Chain of objB. Elsefalse
. - If objA is objB, return
false
// example of isPrototypeOf const xaa = {}; const xbb = {}; // make xaa the parent of xbb Object.setPrototypeOf(xbb, xaa); console.log(xaa.isPrototypeOf(xbb));
// isPrototypeOf returns true for grand parents too const x1 = {}; const x2 = Object.create(x1); const x3 = Object.create(x2); const x4 = Object.create(x3); console.log(x1.isPrototypeOf(x4)); // true
// example of isPrototypeOf on same objects const xx = {}; console.log(xx.isPrototypeOf(xx) === false);
- Return
JavaScript. Object and Inheritance
- JS: Object Tutorial
- JS: Object Overview
- JS: Object Type
- JS: Test is Object Type 📜
- JS: Determine Type of Object
- JS: Prototype and Inheritance
- JS: Prototype Chain
- JS: Object.prototype.isPrototypeOf
- JS: Get Set Prototype
- JS: Show Prototype Chain 📜
- JS: Prototype Tree
- JS: Dot Notation and Prototype Chain
- JS: Create Object
- JS: Object Literal Expression
- JS: Object.create
- JS: Object Literal Expression vs Object.Create
- JS: Create Object with Parent X
- JS: Prevent Adding Property
- JS: Deep Copy Array or Object 📜
- JS: Test Equality of Array and Object by Content 📜
- JS: Add Method to Prototype
- JS: Object (class)
- JS: Object Constructor
- JS: Object.prototype