# 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`.

#### Description

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

An ActionScript object is said to be an instance of a class if the constructor function's prototype object is in the ActionScript object's prototype chain.

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

#### Example

To illustrate the algorithm of the `instanceof` operator, the following example shows how the `instanceof` operator might look if it was coded as an ActionScript function.

    function instanceof (theObject, theClass){
    	while ((theObject = theObject.__proto__) != null) {
               if (theObject == theClass.prototype) {
                      return true;
               }
    	}
    	return false;
    }

#### See also

`typeof`