Google News
logo
UI Developer - Interview Questions
Write a Javascript code snippet, to find specific objects in an array of objects?
We can use Javascript "find" method for the same :
let customers = [
  { id: 0, name: 'free' },
  { id: 1, name: 'time' },
  { id: 2, name: 'learn' }
];
let customer = customers.find(cust => cust.name === 'learn');
console.log(customer);
--> { id: 2, name: 'learn' } 
Advertisement