<script>
    let arr = [1,2,3,3,2,4,3,2];
    let emptyObj = {};
    let otherObj = {};
    arr.forEach(item=>{
      emptyObj[item] = item; //这样也可以数组去重
    })
    console.log(emptyObj); //{1: 1, 2: 2, 3: 3, 4: 4};
    Object.values(emptyObj).forEach((item,index)=>{
      otherObj['a'+index] = [];
      arr.forEach(el=>{
        if(el==item) otherObj['a'+index].push(el);
      })
    });
    console.log(otherObj); 
    /* 输出
      a0: [1]
      a1: (3) [2, 2, 2]
      a2: (3) [3, 3, 3]
      a3: [4]
    */
   //将otherObj 变成数组就好了 
   console.log(Object.values(otherObj)); //[Array(1), Array(3), Array(3), Array(1)]