1.键值对法 (我最喜欢,简单易懂)
Array.prototype._RepeatMost = function () { let _this = [...this]; const obj = {}; let maxTerm = 1; let key = null; _this.forEach((item, index) => { if (obj[item] === undefined) { obj[item] = 1; } else { obj[item] = ++obj[item]; if (maxTerm < obj[item]) { maxTerm = obj[item]; key = item; } } }) return { [key]: maxTerm } } console.log(ary._RepeatMost())