In the following array, which value is considered as the fourth index/position by javascript, in indexOf()
method. Is it "Mango"
or "Banana"
?
var fruits = ["Banana", "Orange", "Apple", "Mango", "Banana", "Orange", "Apple"];
var a = fruits.indexOf("Apple", 4);
答案 0 :(得分:0)
Here is a little tool to play with:
var arr = ["Banana", "Orange", "Apple", "Mango", "Banana", "Orange", "Apple"]
var index = parseInt(prompt("Give an integer between 0 and " + (arr.length - 1)));
alert("At index: " + index + " we find: " + arr[index]);
for (var i = 0; i < arr.length; i++) {
console.log(i, ":", arr[i]);
}