javascript find object in colection by property code example
Example 1: javascript find object by property in array
myObj = myArrayOfObjects.find(obj => obj.prop === 'something');
Example 2: javascript find object in array by property value
const fruits = ['apple', 'banana', 'grapes', 'mango', 'orange'];
const filterItems = (needle, heystack) => {
let query = needle.toLowerCase();
return heystack.filter(item => item.toLowerCase().indexOf(query) >= 0);
}
console.log(filterItems('ap', fruits));
console.log(filterItems('ang', fruits));