js array includes object
let hasMagenicVendor = vendors.some( vendor => vendor['Name'] === 'Magenic' )
js array includes object
let hasMagenicVendor = vendors.some( vendor => vendor['Name'] === 'Magenic' )
angular list contains property
vendors.filter(function(vendor){ return vendor.Name === "Magenic" })
how to Check if an array contains an object in javascript
// To check if an array contains an Object
const myArrayObj = [{
'username': 'Player 1',
'email': '[email protected]'
}, {
'username': 'Player 2',
'email': '[email protected]'
}];
// Create a helper function to compear the objects
const isEqual = (first, second) => {
return JSON.stringify(first) === JSON.stringify(second);
}
const result = myArrayObj.some(e => isEqual(e, {
'username': 'Player 1',
'email': '[email protected]'
}));
console.log(result); // true
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us