var arr = [0, 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 7, 7, 7, 8, 9, 10, 10, 10]
var uniq = arr.reduce((all, next) => {
var exist = all.find(v => v.key === next)
if (exist) {
exist.count += 1
exist.val.push(next)
} else {
all.push({
key: next,
count: 1,
val: [next]
})
}
return all
}, [])
var max = uniq[0]
uniq.forEach(item => {
if (item.count > max.count) {
max = item
}
})
console.log(max.val)
solved How do I get the elements in an array with the highest occurrency? [closed]