Find()

PHOTO EMBED

Sun May 22 2022 21:23:44 GMT+0000 (Coordinated Universal Time)

Saved by @Luduwanda #javascriptreact

//The find() method returns the value of the element of an array
//that FIRST fulfils the condition of a provided test function. Otherwise, undefined is returned.


const arr = [1,3,5,7,9]
//undefined

arr.find(el => el ===5)
//5

arr.find(el => el > 4)
//5

const peopleArray = [{id:1}, {id:4}, {id:7}]
//undefined

peopleArray.find(persom => person.id ===4)
//{id:4}
content_copyCOPY