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
}
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
}
check if two objects are equal javascript
function checkObjEqual(obj1,obj2){
for(let key in obj1){
if(!(key in obj2 )) return false;
if(obj1[key]!==obj2[key])return false;
}
return true;
}
console.log(checkObjEqual({maroon:'#800000',purple :'#800080'},{purple :'#800080',maroon:'#800000'})) //true
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us