var Arr = [
{key: "0", value: "00"},
{key: "1", value: "11"},
];
var obj={ };
//for in 循环方式
for (var item in Arr){
obj[Arr[item].key] = Arr[item].value;
};
结果打印:
image.png
var Arr = [
{key: "0", value: "00"},
{key: "1", value: "11"},
];
var obj={ };
//for in 循环方式
for (var item in Arr){
obj[Arr[item].key] = Arr[item].value;
};
结果打印:
本文标题:将数组转化为一个对象obj,键值对形式{}
本文链接:https://www.haomeiwen.com/subject/sqrzcktx.html
网友评论