instanceof

Availability

Flash Player 6.

Usage

object instanceof class

Parameters

object An ActionScript object.

class A reference to an ActionScript constructor function, such as String or Date.

Returns

If object is an instance of class, instanceof returns true; otherwise, instanceof returns false. Also, _global instanceof Object returns false.

Description

Operator; determines whether an object belongs to a specified class. Tests whether object is an instance of class.

The instanceof operator does not convert primitive types to wrapper objects. For example, the following code returns true:

new String("Hello") instanceof String;

Whereas the following code returns false:

"Hello" instanceof String;

See also

typeof