JavaScript Find an item in the array of objects

Below is an example of finding an item from an array in JavaScript, we can use .find over an array to do that.

let arrayOfObjects = [{
    firstName: "Peter",
    lastName: "Smith",
    Age: 10
  },
  {
    firstName: "Roger",
    lastName: "Ross",
    Age: 20
  }
];

let itemFromArray = arrayOfObjects.find(o => o.firstName === 'Roger');

console.log(itemFromArray);

The output itemFromArray will be the item we found with the desired firstName.