对象:
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;