发布网友 发布时间:2022-04-23 01:59
共1个回答
热心网友 时间:2023-10-06 15:25
var obj = {"pieTes":[{"colors":"Sony","value":7},{"colors":"Samsumg","value":14},{"colors":"LG","value":21},{"colors":"Vizio","value":34},{"colors":"Insignia","value":24}]};
var arr = new Array();
for(var i in x.pieTes) {
arr.push([x.pieTes[i].colors, x.pieTes[i].value]);
}
alert(arr);
// 输出 Sony,7,Samsung,14,LG,21,Vizio,34,Insignia,24
alert 不会以数组形式显示,实际结果应该如图所示 console.log(arr);