Answers for "how to check if object inside an array has the same values in js"

9

check if array has same values javascript

const allEqual = arr => arr.every(v => v === arr[0]);
allEqual([1,1,1,1]);  // true
Posted by: Guest on May-27-2020
2

js check if array of objects contains duplicates

const arrayOfObjCopy = [...arrayOfObj];

Object.keys(arrayOfObjCopy).forEach((key) => {
  arrayOfObjCopy[key] = JSON.stringify(arrayOfObjCopy[key]);
 });

const arrayOfObjhasDuplicates = uniq(arrayOfObjCopy).length != arrayOfObjCopy.length;
Posted by: Guest on November-17-2020

Code answers related to "how to check if object inside an array has the same values in js"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language