[1,1,1,1,1, 3,3,3,3,3, 5,5 ,6,6,6, 7,7,7,7,7]
[1,3,7]
const arr = [1,1,1,1,1, 3,3,3,3,3, 5,5 ,6,6,6, 7,7,7,7,7];
const calc = arr.reduce((prev, curr) => {
const idx = prev.findIndex(item => item.val === curr);
if (idx !== -1) {
return ++prev[idx].count && prev;
} else {
return prev.push({ val: curr, count: 1 }) && prev;
}
}, []);
const max = Math.max(...calc.map(i => i.count));
const result = calc.filter(i => i.count === max).map(i => i.val);
console.log(result); // [1, 3, 7]
[1,1,1,1,1, 3,3,3,3,3, 5,5 ,6,6,6, 7,7,7,7,7].filter((v, i, a) => a.indexOf(v) === i);