is javascript includes work for object code example

Example: 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': 'john.doe@example.com'
}, {
    'username': 'Player 2',
    'email': 'jane.doe@example.com'
}];

// 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': 'john.doe@example.com'
}));

console.log(result); // true