Code to compare if two objects are the same

1  // Compare whether two objects are the same 
2  var xm= {
 3      age:18 ,
 4      score:4
 5  }
 6  var xh= {
 7      age:18 ,
 8      score:4
 9  };
 10  function equalObjs(a,b) {
 11      for ( var p in a){
 12          if (a[p]!==b[p]) return  false ;
 13      }
 14      return  true ;
 15 }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325173868&siteId=291194637