对象转换数组

对象:

 var scoreObject = {
    "Tony": {
        "Math": 95,
        "English": 79,
        "Music": 68
    }, 
    "Simon": {
        "Math": 100,
        "English": 95,
        "Music": 98
    }, 
    "Annie": {
        "Math": 54,
        "English": 65,
        "Music": 88
    }
}

代码

var arr = [];
for(var i in scoreObject) {
  var arrW = []
  arrW.push(i);
  for(var j in scoreObject[i]) {
    arrW.push(scoreObject[i][j])
  }
  arr.push(arrW);
}
console.log(arr);
p.innerHTML = arr;
上一篇:AudioTrack中MODE_STATIC和MODE_STREAM的差异


下一篇:Installation of the latest version of netease-cloud-music on Fedora 30 linux platform