js数组转换
作者:互联网
var data ={id:"11",name:"张三"};
var keyMap = {id: "序列", name: "姓名"};
var objs = Object.keys(data).reduce((newData, key) => {
let newKey = keyMap[key] || key
newData[newKey] = data[key]
return newData;
}, {})
console.log("----------------------",objs)
标签:objs,转换,数组,js,keyMap,key,var,data,newData 来源: https://blog.csdn.net/weixin_48164217/article/details/121116851