标签:++ ons turn nbsp value false === cti sort
Array.prototype.repeat = function(){ let shipObj = this.reduce((pre, cur)=>{ pre[cur] ? pre[cur]++ : pre[cur] = 1; return pre; }, {}) // console.log(arguments.length) // arguments let valList = Object.values(shipObj).sort((m,n)=>n-m); Object.keys(shipObj).forEach(key=>{ valList.some((val,i)=>{ if(shipObj[key] === val){ valList[i] = [key, shipObj[key]]; return true; } return false }) }) return valList; } var nn = [‘Tiff‘, ‘Alice‘, ‘Tiff‘, ‘Bruce‘, ‘Alice‘, ‘Bob‘]; var res = nn.repeat()
标签:++ ons turn nbsp value false === cti sort
原文地址:https://www.cnblogs.com/liujinyu/p/12005575.html