1var array = [1, 2, 2, 3, 3, 4, 5, 6, 2, 3, 7, 8, 5, 22, 1, 2, 511, 12, 50, 22];
2
3console.log([...new Set(
4 array.filter((value, index, self) => self.indexOf(value) !== index))]
5);
1var counts = {};
2your_array.forEach(function(x) { counts[x] = (counts[x] || 0)+1; });
1var input = [1, 2, 3, 1, 3, 1];
2
3var duplicates = input.reduce(function(acc, el, i, arr) {
4 if (arr.indexOf(el) !== i && acc.indexOf(el) < 0) acc.push(el); return acc;
5}, []);
6
7document.write(duplicates); // = 1,3 (actual array == [1, 3])