let arr1 = [
{
Num: "0001",
chr_Beijing: "xx",
chr_Shanghai: "xx"
},
{
Num: "0002",
chr_Beijing: "xx",
chr_Shanghai: "xx"
},
{
Num: "0003",
chr_Beijing: "xx",
chr_Shanghai: "xx"
}
]
let arr2 = [
{
Num: "0001",
Type: "T1",
T1_Beijing: "",
chr_Beijing: "xx",
T1_Shanghai: "",
chr_Shanghai: "xx"
},
{
Num: "0002",
Type: "T2",
T2_Beijing: "",
chr_Beijing: "xx",
T2_Shanghai: "",
chr_Shanghai: "xx"
},
{
Num: "0003",
Type: "T3",
T3_Beijing: "",
chr_Beijing: "xx",
T3_Shanghai: "",
chr_Shanghai: "xx"
}
]
想实现:
我的初始数据如arr1这样的对象数组,有近千条各地的数据,想转换成arr2,自动加入下面的属性:
- 根据arr1的Num值,生成arr2的 Type属性,值为Num值去掉0的整数,并在前加“T”字符。
- 根据arr1中的属性名 chr_后的地名,与Type的值,合并成新的属性名,值为空。并自动插入相应的数组对象中。
恳请指教!