instanceof Operator

Using the instanceof operator, you can test if an object was created with a specific constructor function.

function Hero(){}
var h = new Hero();
var o = {};
h instanceof Hero;
true

h instanceof Object;
false

o instanceof Object;
true

Note that you don't put parentheses after the function name (don't use h instanceof Hero()). This is because you're not invoking this function, but just referring to it by name, as for any other variable.

Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents