check if value is in object javascript code example
Example 1: javascript if field exists
const hero = {
name: 'Batman'
};
hero.hasOwnProperty('name'); // => true
hero.hasOwnProperty('realName'); // => false
Example 2: check if property has value in array javascript
const magenicVendorExists = vendors.reduce((accumulator, vendor) => (accumulator||vendor.Name === "Magenic"), false);
Example 3: check if field exists in object javascript
if ('field' in obj) {
}