Zählen Sie doppelte Werte JavaScript
var counts = {};
your_array.forEach(function(x) { counts[x] = (counts[x] || 0)+1; });
Xanthous Xenomorph
var counts = {};
your_array.forEach(function(x) { counts[x] = (counts[x] || 0)+1; });
var input = [1, 2, 3, 1, 3, 1];
var duplicates = input.reduce(function(acc, el, i, arr) {
if (arr.indexOf(el) !== i && acc.indexOf(el) < 0) acc.push(el); return acc;
}, []);
document.write(duplicates); // = 1,3 (actual array == [1, 3])