js includes in object code example
Example 1: js does object contain value
var obj = { a: 'test1', b: 'test2' };
if (Object.values(obj).indexOf('test1') > -1) {
console.log('Value exists!');
}
Example 2: angular list contains property
vendors.filter(function(vendor){ return vendor.Name === "Magenic" })
Example 3: javascript object includes
const person = {
first_name: "Sam",
last_name: "Bradley"
};
Object.values(person).includes("Bradley");
Example 4: javascript array contains object
if (array.index(object) !== -1) {
console.log(`my object is in my array`)
}
if(array.includes(oject)) {
console.log(`my object is in my array`)
}