JS: Object.prototype.isPrototypeOf
objA.isPrototypeOf(objB)-
- Return
trueif objA is in Prototype Chain of objB. Elsefalse. - If objA is objB, return
false
// example of isPrototypeOf const xdad = {}; const xson = {}; // make xdad the parent of xson Object.setPrototypeOf(xson, xdad); console.assert(xdad.isPrototypeOf(xson)); // isPrototypeOf returns true for grand parents too const xgen1 = {}; const xgen2 = Object.create(xgen1); const xgen3 = Object.create(xgen2); const xgen4 = Object.create(xgen3); console.assert(xgen1.isPrototypeOf(xgen4)); // example of isPrototypeOf on same objects const xx = {}; console.log(xx.isPrototypeOf(xx) === false); - Return
JavaScript. Object and Inheritance
- JS: Object (basics)
- JS: Object Overview
- JS: Object Type
- JS: Test is Object Type 📜
- JS: Find Object's sub-type
- 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