JS: Object .prototype .isPrototypeOf
A.isPrototypeOf(B)-
- Return
trueif A is in Prototype Chain of B. Elsefalse. - If A is B, return
false
// example of isPrototypeOf const xdad = {}; const xson = Object.create(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.assert(xx.isPrototypeOf(xx) === false); - Return