instanceof (Operator/logical)

Checks to see if an object is an instance of another object.

Availability:

ECMAScript edition - 3
JavaScript - 1.5
JScript - 5.0
Internet Explorer - 5.0
Netscape - 6.0
Property/method value type:Boolean primitive
JavaScript syntax:-anObject instanceof anotherObject
Argument list:anObjectThe object to test
anotherObject the object to test against-

The object referred to by the left operand is examined, and its type compared with the type of the object on the right. The object on the right should be an object with a constructor (that is, a class object) although this likely works with instances as well if they also have constructors inherited.

The ECMA standard (second edition) reserves this keyword for future use in anticipation of the JavaScript 1.4 implementation. That means that a compliant implementation does not need to support this feature.

This operator yields the true value if both objects are of the same class, otherwise it is false.

Warnings:

See also:Reserved word

Cross-references:

ECMA 262 edition 2 - section - 7.4.3

ECMA 262 edition 3 - section - 11.8.6