check if 2 object are the same node code example

Example 1: Javascript compare two objects

var person1={first_name:"bob"};
var person2 = {first_name:"bob"}; 

//compare the two object
if(JSON.stringify(person1) === JSON.stringify(person2)){
    //objects are the same
}

Example 2: javascript check if objects are equal

const isEqual = (...objects) => objects.every(obj => JSON.stringify(obj) === JSON.stringify(objects[0]));

// Examples
isEqual({ foo: 'bar' }, { foo: 'bar' });    // true
isEqual({ foo: 'bar' }, { bar: 'foo' });    // false