myObject.isPrototypeOf( instanceToTest ) in ECMAScript 262
Determines if the calling object prototype is in the inheritance chain for the supplied argument.
Arguments
name | type | description |
---|---|---|
instanceToTest | Object | The object instance to check.< |
- Return Type
- Boolean
Description
The following code sample shows how to use this method to test if an object instance inherits from the calling prototype:
function Mammal(){ ... }
function Human(){ ... }
Human.prototype = new Mammal; //Human inherits from Mammal
var billGates = new Human();
if (Human.isPrototypeOf(billGates)){
//this code will NOT run...
//you must call this method on a prototype object
}
if (Human.prototype.isPrototypeOf(billGates)){
//this code will run...the above will return true
}
if (Mammal.prototype.isPrototypeOf(billGates)){
//this code will run...the above will return true
}