Answers for "array find on object"

2

find item in object js

const object1 = {
  a: {val: "aa"},
  b: {val: "bb"},
  c: {val: "cc"}
};

let a = Object.values(object1).find((obj) => {
	return obj.val == "bb"
});
console.log(a)
//Object { val: "bb" }
//Use this for finding an item inside an object.
Posted by: Guest on May-10-2021
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
7

javascript find object in array

myArray.findIndex(x => x.id === '45');
Posted by: Guest on September-15-2020
0

javascript find object array

const found = accesses.find(x => x.Resource === 'Clients');
console.log(found)
Posted by: Guest on February-25-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language