js 判断一个元素是否在数组中

(1).let arr = [1,2,3];

arr.includes(1) // true

arr.includes(5) //false

(2).a=["1", "3", "2", "3", "0"];

console.log(a.indexOf ('3'));//1

console.log(a.indexOf ('4'));//-1

posted on 2022-04-27 10:16  paike123  阅读(43)  评论(0编辑  收藏  举报

导航