28 lines
661 B
JavaScript
28 lines
661 B
JavaScript
|
const { type } = require("os");
|
||
|
|
||
|
const equal = function(obj1, obj2) {
|
||
|
|
||
|
if(obj1 === obj2){
|
||
|
return true;
|
||
|
} else if(typeof(obj1) !== 'object' || typeof(obj2) !== 'object') {
|
||
|
return false
|
||
|
}
|
||
|
else {
|
||
|
let Isequal = true;
|
||
|
for (const [key, value] of Object.entries(obj1)) {
|
||
|
if(value !== obj2[key]) {
|
||
|
console.log(key, value, obj2[key])
|
||
|
return false
|
||
|
}
|
||
|
}
|
||
|
for (const [key, value] of Object.entries(obj2)) {
|
||
|
if(value !== obj1[key]) {
|
||
|
return false
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return true
|
||
|
}
|
||
|
|
||
|
|
||
|
module.exports = { equal }
|