控制台输出重复元素的个数

let arr = ['a', 'b', '2', 'w', 'a', 'a', 'b']
let b = [...new Set(arr)]
let len = b.length,i
for(i=0;i<len;i++) {
  let num = arr.filter(item => {
    return item == b[i]
  }).length
  console.log(`${b[i]}:${num}`)
}

javascript输出数组里重复元素的个数_i++