Answers for "find how many similar object item in an array in javascript"

2

how to find duplicate item in array of object in javascript

const values = [
  { name: 'someName1' },
  { name: 'someName2' },
  { name: 'someName3' },
  { name: 'someName1' }
]

const uniqueValues = new Set(values.map(v => v.name));

if (uniqueValues.size < values.length) {
  console.log('uniqueValues')
}
Posted by: Guest on December-10-2020
0

find how many similar object item in an array in javascript

const counts = {};
your_array.forEach(function(x.name) { counts[x.name] = (counts[x.name] || 0)+1; });
Posted by: Guest on October-07-2021

Code answers related to "find how many similar object item in an array in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language