Answers for "search in array typescript"

50

javascript find

const inventory = [
  {name: 'apples', quantity: 2},
  {name: 'cherries', quantity: 8}
  {name: 'bananas', quantity: 0},
  {name: 'cherries', quantity: 5}
  {name: 'cherries', quantity: 15}
  
];

const result = inventory.find( ({ name }) => name === 'cherries' );

console.log(result) // { name: 'cherries', quantity: 5 }
Posted by: Guest on July-11-2020
0

find value in array ts

this.persons =  this.personService.getPersons().find(x => x.id == this.personId);
Posted by: Guest on March-20-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language