方法一
使用 indexOf 方法,返回查找元素在数组中第一次出现位置(下标值),否则返回-1
var a=["1", "3", "2", "3", "0"];
console.log(a.indexOf ('3'));//1
console.log(a.indexOf (5,'0'));//-1
console.log(a.indexOf ('0'));//4
console.log(a.indexOf ('0',-5));//4
console.log(a.indexOf ('3',-1));//-1
console.log(a.indexOf ('3',-3));//3
console.log(a.indexOf ('1',5));//-1
console.log(a.indexOf (3));//-1
console.log(a);//["1", "3", "2", "3", "0"]
方法二
属于ES语法,使用 includes 方法,返回值是布尔类型
let arr = [1,2,3];
arr.includes(1) // true
arr.includes(5) //false