Es6数组 处理方法
作者:互联网
ES6 引入了许多有用的数组方法,例如:
- find(),查找列表中的成员,返回 null 表示没找到
- findIndex(),查找列表成员的索引
- some(),检查某个断言是否至少在列表的一个成员上为真
- includes,列表是否包含某项
const array = [{ id: 1, checked: true }, { id: 2 }]; arr.find(item => item.id === 2) // { id: 2 } arr.findIndex(item => item.id === 2) // 1 arr.some(item => item.checked) // true const numberArray = [1,2,3,4]; numberArray.includes(2) // true Promises + Async/Await
标签:Es6,arr,处理,some,列表,item,数组,true,id 来源: https://www.cnblogs.com/yyy2020/p/16420328.html