javascript get object with key from array code example
Example 1: get all keys of object in javascript
myObject = {
"key": "value",
"key2":"value2"
}
Object.keys(myObject);
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));