Answers for "how do i find duplicate values in array"

2

how to get duplicate values from array in javascript

var array = [1, 2, 2, 3, 3, 4, 5, 6, 2, 3, 7, 8, 5, 22, 1, 2, 511, 12, 50, 22];

console.log([...new Set(
  array.filter((value, index, self) => self.indexOf(value) !== index))]
);
Posted by: Guest on June-19-2020
1

find duplicates and their count in an array javascript

var counts = {};
your_array.forEach(function(x) { counts[x] = (counts[x] || 0)+1; });
Posted by: Guest on May-12-2020

Code answers related to "how do i find duplicate values in array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language