欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

返回的对象保存到二维数组的实例代码分享

程序员文章站 2022-05-24 14:28:10
...
var result={"a":{"x":5,"y":0,"z":0},"b":{"x":0,"y":0,"z":3},"c":{"x":5,"y":0,"z":0},"d":{"x":0,"y":0,"z":4},"e":{"x":0,"y":3,"z":0}
};var arr=[];var obj={
    keyArr:['dec'],
    one:['x'],
    two:['y'],
    three:['z']
};for(var key in result){
    obj.keyArr.push(key);var thisResult=result[key];
    obj.one.push(thisResult.x);
    obj.two.push(thisResult.y);
    obj.three.push(thisResult.z);
}//obj.one.unshift("x");//obj.two.unshift("y");//obj.three.unshift("z");for(var i in obj){
    arr.push(obj[i]);
}
console.log(arr);

返回的对象保存到二维数组的实例代码分享

以上就是返回的对象保存到二维数组的实例代码分享的详细内容,更多请关注其它相关文章!