get an item in a object thats in a array code example
Example 1: javascript get array object by id
myArray.find(x => x.id === '45').foo;
Example 2: find particular object from array in js
let arr = [
{ name:"string 1", value:"this", other: "that" },
{ name:"string 2", value:"this", other: "that" }
];
let obj = arr.find((o, i) => {
if (o.name === 'string 1') {
arr[i] = { name: 'new string', value: 'this', other: 'that' };
return true;
}
});
console.log(arr);
Example 3: search an array of objects with specific object property value
var result = jsObjects.find(obj => {
return obj.b === 6
});