Javascript function
Write a function, deepEqual
, that takes two values and returns true only if they are the same value or are objects with the same properties whose values are also equal when compared with a recursive call to deepEqual
.
var obj = {here: {is: “an”}, object: 2};
console.log(deepEqual(obj, obj));
// → true
console.log(deepEqual(obj, {here: 1, object: 2}));
// → false
console.log(deepEqual(obj, {here: {is: “an”}, object: 2}));
// → true
Node : module to do it
Via node JS you can use : https://www.npmjs.com/package/deep-equal
Node : Assert methods to compare two objects
If you are want comapare the objects for a test, you can use : https://nodejs.org/api/assert.html