indexOf() 方法返回在数组中可以找到一个给定元素的第一个索引,如果不存在,则返回-1。

const list = [1, 2, 3, 4, 5];
list.indexOf(2); // 1
list.indexOf(8); // -1