es6 check if object exists in array code example
Example 1: check object in array javascript
var obj = {a: 5};
var array = [obj, "string", 5]; // Must be same object
array.indexOf(obj) !== -1 // True
Example 2: check if property has value in array javascript
const magenicVendorExists = vendors.reduce((accumulator, vendor) => (accumulator||vendor.Name === "Magenic"), false);