object includes javascript 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: javascript object includes
const person = {
first_name: "Sam",
last_name: "Bradley"
};
Object.values(person).includes("Bradley");
Example 3: check if property has value in array javascript
const magenicVendorExists = vendors.reduce((accumulator, vendor) => (accumulator||vendor.Name === "Magenic"), false);
Example 4: javascript includes method
arr.includes(searchElement[, fromIndex = 0])