array.findIndex((obj) => obj.id === obj.id) !== -1
if (vendors.findIndex(item => item.Name == "Magenic") == -1) {
//not found item
} else {
//found item
}
var obj = {a: 5};
var array = [obj, "string", 5]; // Must be same object
array.indexOf(obj) !== -1 // True
let hasMagenicVendor = vendors.some( vendor => vendor['Name'] === 'Magenic' )
const john = {
'name': 'John Doe',
'email': 'john.doe@example.com'
};
const jane = {
'name': 'Jane Doe',
'email': 'jane.doe@example.com'
};
const list = [john, jane];
let result = list.includes(john);
console.log(result); // true
const list = [{
'name': 'John Doe',
'email': 'john.doe@example.com'
}, {
'name': 'Jane Doe',
'email': 'jane.doe@example.com'
}];
const isEqual = (first, second) => {
return JSON.stringify(first) === JSON.stringify(second);
}
const result = list.some(e => isEqual(e, {
'name': 'John Doe',
'email': 'john.doe@example.com'
}));
console.log(result); // true