自定义对象的键

2020-03-06  本文已影响0人  冬天的_太阳
    let data = [{className: '13班级',sore: '88'},{className: '10班级',sore: '11'}, {className: '19班级',sore: '22'}];
    let obj = {};
    let scoreData = data.map((item,index) => {
          return  obj["className"+index] = item.sore
    })
    console.log(obj);/// {className0: "88" ,className1: "11",className2: "22"},
上一篇下一篇

猜你喜欢

热点阅读