Answers for "check if all object is same javascript"

9

javascript check if objects are equal

const isEqual = (...objects) => objects.every(obj => JSON.stringify(obj) === JSON.stringify(objects[0]));

// Examples
isEqual({ foo: 'bar' }, { foo: 'bar' });    // true
isEqual({ foo: 'bar' }, { bar: 'foo' });    // false
Posted by: Guest on July-03-2020
1

array of objects how to check if property has duplicate

var yourArray = [

{Index: 1, Name: "Farley, Charley", EmployeeCode: "12", PaymentType: "Void", CheckDate: "01/04/2012"},
{Index: 2, Name: "Farley, Charley", EmployeeCode: "12", PaymentType: "Void", CheckDate: "01/04/2012"},
{Index: 3, Name: "Tarley, Charley", EmployeeCode: "12", PaymentType: "Void", CheckDate: "01/04/2012"}
];

   unique = [...new Set(yourArray.map(propYoureChecking => propYoureChecking.Name))];
if (unique.length === 1) {
console.log(unique);
}
Posted by: Guest on May-20-2020
1

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
Posted by: Guest on June-23-2021

Code answers related to "check if all object is same javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language