Object control find/map/filter

Darcy Daeseok YU ·2022년 2월 10일
0

Find a Object !

const datas = [{id: 1 , ... } ,{id: 2 , ... } ,{id: 3 , ... } ]

1.find() : return object{}

datas.find(data => data.id===1 ? data : null)
datas.find(data => data.id===1)
{id: 1}
  1. map() : return []
datas.map(data => data.id===1 ? data : null) 
(3) [{…}, null, null]

datas.map(data => data.id===1) 
[true, false, false]

3.filter() : return []

datas.filter(data => data.id===1)
[{…}]

4.findIndex() : return index number

profile
React, React-Native https://darcyu83.netlify.app/

0개의 댓글