const arr = [{a: 1}, {b: 1}, {a: 1}]
arr.find(e => e.a === 1) // {a: 1}
arr.filter(e => e.a === 1) // [{a: 1}, {a: 1}]
“ 平时一直都在用Array.filter,有一天突然想起Array.find;那么filter和find到底有什么区别? ”
const arr = [{a: 1}, {b: 1}, {a: 1}]
arr.find(e => e.a === 1) // {a: 1}
arr.filter(e => e.a === 1) // [{a: 1}, {a: 1}]