|
Array.indicesOf Method
Returns an array containing the indices of the elements of an Array that contain a specific value.
object.indicesOf (value)
Arguments
- object
- Required. Always the name of an Array object.
- value
- Required. The value to search for within the Array object.
Return Value
The Array.indicesOf method returns the following values:
If |
Array.indicesOf returns |
value is the value of an element of object |
an Array whose element values are the indices of the
elements in object whose values match value |
value is not the value of an element of object |
an Array containing a single element with a value of -1 |
Remarks
The following example illustrates the use of the Array.indicesOf method.
var a = new Array("a", "c", "b", "d", "b");
Console.Writeln(a.indicesOf("k").toString()); // returns -1
Console.Writeln(a.indicesOf("b").toString()); // returns 2,4
Console.Writeln(a.indicesOf("d").toString()); // returns 3
Requirements
|