Example
Search an array for the item "Apple":
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var a = fruits.indexOf("Apple");
var a = fruits.indexOf("Apple");
The result of a will be:
2
Meaning that "Apple" is located at position 2 in the array.
沒有留言:
張貼留言