This documentation is archived and is not being maintained.

Array.contains Function

Visual Studio 2008

Determines whether the specified object exists as an element in an Array object. This function is static and can be invoked without creating an instance of the object.

var itemExists = Array.contains(array, item);

Term

Definition

array

The array to search.

item

The object to find in the array.

true if the specified object exists as an element in the array; otherwise, false.

Use the contains function to determine whether a specified object exists as element in an Array object.

In Mozilla Firefox, calling the contains function with item set to undefined returns true if an item in the array has been set to undefined. In all other browsers, the function returns false in these circumstances.

The following example shows how to use the contains function to determine whether an array contains a specified element.

Show: