Ver originalvar arr = [2,1,3,6,2,4,5,3,5,6]; var rep = arr.reduce(function(p,c){ if (c in p) { p[c]++; } else { p[c] = 1; } return p;}, {}); console.log(rep); // Object {1: 1, 2: 2, 3: 2, 4: 1, 5: 2, 6: 2}