Categories
javascript

How to use array.find() with Object.entries()

This example uses array destructuring. Object.entries() returns an array.

const usersObject = {
  'John': 'Doe',
  'Oliver': 'Jones',
  'Alex': 'Lones',
}

const foundUser = Object.entries(usersObject)
  .find(([key, value]) => key === 'Oliver' && value === 'Jones');

console.log(foundUser); // [ 'Oliver', 'Jones' ]