So finden Sie den Index eines Wertes in einem Array in JavaScript
var list = ["apple","banana","orange"]
var index_of_apple = list.indexOf("apple") // 0
Clumsy Crayfish
var list = ["apple","banana","orange"]
var index_of_apple = list.indexOf("apple") // 0
var array = [2, 9, 9];
array.indexOf(2); // 0
array.indexOf(7); // -1
array.indexOf(9, 2); // 2
array.indexOf(2, -1); // -1
array.indexOf(2, -3); // 0
const fruits = ["Apple", "Orange", "Apple", "Mango"];
let position = fruits.indexOf("Apple") + 1;