find 跟 some 都是对数组的遍历操作,其主要的区别是
find返回满足条件的第一项
some找到符合条件的项后返回布尔值
let arr = [
{
name: "xiaoming",
age: 1
},
{
name: 'xiaoming',
age: 2
}
];
let item = arr.find(item => item.name == 'xiaoming');
console.log(item ); // { name: "xiaoming", age: 1}
let item = arr.some(item => item.name == 'xiaoming');
console.log(item); // true