object-is-equal
v1.2.4
Published
JS library to compare to object and array equality
Downloads
9
Maintainers
Readme
object-is-equal
JS library to compare to object and array equality
This can be used to compare two nested arrays, two nested objects, two nested array of objects or nested object of arrays.
install
npm install object-is-equal
uses
const objectEqual = require('object-is-equal');
const obj1 = {
a: 10,
b: 20
};
const obj2 = {
a: 10,
b: 20
};
console.log(objectEqual(obj1, obj2)); // true
-----------------------------------------------
const obj1 = {
a: {
c: 30
},
b: {
d: 40
}
};
const obj2 = {
a: {
c: 30
},
b: {
d: 40
}
};
console.log(objectEqual(obj1, obj2)); // true
-------------------------------------------------
const obj1 = {
a: {
c: 30
},
b: {
d: 40
}
};
const obj2 = {
a: {
c: 30,
d: 44
},
b: {
d: 40
}
};
console.log(objectEqual(obj1, obj2)); // false
-------------------------------------------------
const obj1 = [{
a: {
c: 30
},
b: {
d: 40
}
}];
const obj2 = [{
a: {
c: 30,
},
b: {
d: 40
}
}];
console.log(objectEqual(obj1, obj2)); // true
-------------------------------------------------
const obj1 = [
[1,2,3],
[4,5,6],
[7,8,9]
];
const obj2 = [
[1,2,3],
[4,5,6],
[7,8,9]
];
console.log(objectEqual(obj1, obj2)); // true