标签:item this OLE fine type log span console ret
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())
标签:item this OLE fine type log span console ret
原文地址:https://www.cnblogs.com/MrZhujl/p/13174160.html