📅  最后修改于: 2022-03-11 15:02:41.038000             🧑  作者: Mango
function getMostFrequent (arr) {
const hashmap = arr.reduce ((acc, val) => {
acc [val] = (acc [val] || 0) + 1
return acc
}, {})
return Object.keys (hashmap ) .reduce ((a, b) => hashmap [a]> hashmap [b]? a: b)
}