I have an array like
vendors = [{
Name: \'Magenic\',
ID: \'ABC\'
},
{
Name: \'Microsoft\',
ID: \'DEF\'
} // and so on...
];
As the OP has asked the question if the key exists or not.
A more elegant solution that will return boolean using ES6 reduce function can be
const magenicVendorExists = vendors.reduce((accumulator, vendor) => (accumulator||vendor.Name === "Magenic"), false);
Note: The initial parameter of reduce is a false
and if the array has the key it will return true.
Hope it helps for better and cleaner code implementation