1const jsObjects = [
2 {id: 1, displayName: "First"},
3 {id: 2, displayName: "Second"},
4 {id: 3, displayName: "Third"},
5 {id: 4, displayName: "Fourth"}
6]
7
8// You can use the arrow function expression:
9var result = jsObjects.find(obj => {
10 // Returns the object where
11 // the given property has some value
12 return obj.id === 1
13})
14
15console.log(result)
16
17// Output: {id: 1, displayName: "First"}
1// To find a specific object in an array of objects
2myObj = myArrayOfObjects.find(obj => obj.prop === 'something');