var arr = [10,11,12,13];
function judge(obs) {
const res = arr.some(item => item === obs)
const res = arr.find(item => item === obs)
const res = arr.indexOf(obs)
const res = arr.filter(item => item === obs)
arr = arr.filter(item => item !== obs) // 推荐使用
const res = arr.findIndex(item => item === obs)
}
判断数组中是否存在某一个值的方法
最新推荐文章于 2024-07-04 22:22:07 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)