isPrototypeOf

Every object gets the isPrototypeOf() method. Using this method we can find if the specific object is used as a prototype of another object.

Create a simple object monkey.

var monkey = {
    hair: true,
    feeds: 'bananas',
    breathes: 'air'
};

Create a Human() constructor function and set its prototype property to point to monkey.

function Human(name) {
    this.name = name;
}
Human.prototype = monkey;

Now create a new Human object called george and check if monkey is prototype of george. It will return true.

var george = new Human('George');

monkey.isPrototypeOf(george)
true
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +