JS: Object.prototype.isPrototypeOf
root.isPrototypeOf(branch)
-
Return
true
if root is in Prototype Chain of branch. Elsefalse
.If root is branch, return
false
// example of isPrototypeOf const j1 = { "j1k": 1 }; const j2 = { "j2k": 1 }; Object.setPrototypeOf(j2, j1); console.log(j1.isPrototypeOf(j2));
// isPrototypeOf returns true for grand parents too const t1 = {}; const t2 = Object.create(t1); const t3 = Object.create(t2); const t4 = Object.create(t3); console.log(t1.isPrototypeOf(t4));
// example of isPrototypeOf on same objects const tt = {}; console.log(tt.isPrototypeOf(tt) === false);
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: Create Object with Parent X
- JS: Prevent Adding Property
- JS: Deep Copy Object, Array 🚀
- JS: Test Object Equality 🚀
- JS: Add Method to Prototype
- JS: Object Object
- JS: Object Constructor
- JS: Object.prototype