Main Menu

Categories

Subscribe

The instanceof Operator in JavaScript

April 6th, 2009

The instanceof operator expects a left-side operand that is an object and a right-side operand that is the name of a class of objects.

var names = new String("Keith");
names instanceof String;
// returns true

var names2 = "Aoife";
names2 instanceof String;
// returns false (names2 is not a String object)

No Comments

Leave a Reply