1.indexOf()返回给定元素在数组内的索引值,如果不存在则返回-1 var arr=[0,1,2,3,4,5] console.log(arr.indexOf(1)) console.log(arr.indexOf(1,2)) //-1 console.log(arr.indexOf(6)) //-1 2.ES6方法 let arr=[0,1,2,5,7,9] arr.includes(0) //true arr.includes(0,2) //false arr.includes(8)…