IR Framework

Array.indexOf Method

Returns the index of the first occurance a value in the Array.
object.indexOf (value[, startIndex])

Arguments

object
Required. Always the name of an Array object.


value
Required. The value to search for within the Array object.


startIndex
Optional. Integer value specifying the index to begin searching within the Array object. If omitted, searching starts at the beginning of the Array.



Return Value

The Array.indexOf method returns the following values:
If Array.indexOf returns
value is the value of an element of object whose index is between startIndex and object.length the index of the first element that contains exactly value
value is not the value of an element of object whose index is between startIndex and object.length -1

Remarks

The following example illustrates the use of the Array.indexOf method.

var a = new Array("a", "c", "b", "d", "b");

Console.Writeln(a.indexOf("k"));			//	returns -1
Console.Writeln(a.indexOf("b"));			//	returns 2
Console.Writeln(a.indexOf("b", 3));			//	returns 4
Console.Writeln(a.indexOf("c", 3));			//	returns -1


Requirements