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 xt1 = {}; const xt2 = Object.create(xt1); const xt3 = Object.create(xt2); const xt4 = Object.create(xt3); console.log(xt1.isPrototypeOf(xt4));
// 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: 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