当前位置:网站首页>两个数组中用第二个数组的Value对比换第一个数组中的Key
两个数组中用第二个数组的Value对比换第一个数组中的Key
2022-08-04 12:22:00 【lyudev】
<script type="text/javascript">
var data = [
{
efge: "333",
test1: "111",
test1243: "222",
createBy: "admin",
createTime: "2022-07-28 10:50:52",
id: "1552486719464116226",
planCode: "avc",
_XID: "row_103",
},
{
efge: "123",
test1: "456",
test1243: "789",
createBy: "admin",
createTime: "2022-07-28 10:50:52",
id: "1552486719464116230",
planCode: "avc",
_XID: "row_103",
},
];
var data1 = [
{
indexDesc: "efge",
indexName: "decimal_field1",
},
{
indexDesc: "test1",
indexName: "implement_rule",
},
{
indexDesc: "test1243",
indexName: "assessment_item",
},
];
function valueChangeKey(data, data1) {
var keys = [];
var values = [];
for (var i = 0; i < data1.length; i++) {
keys.push(data1[i].indexDesc);
values.push(data1[i].indexName);
}
for (var j = 0; j < data.length; j++) {
for (var i = 0; i < keys.length; i++) {
if (data[j][keys[i]]) {
data[j][values[i]] = data[j][keys[i]];
delete data[j][keys[i]];
}
}
}
console.log(data);
return data;
}
valueChangeKey(data, data1);
</script>
边栏推荐
猜你喜欢
如何治理资源浪费?百度云原生成本优化最佳实践
MOSFET米勒平台(Miller Plateau)
活动报名:如何高效应对当下的实时场景需求?
【VBox】解决复制VBox虚拟机后提示硬盘UUID 已经存在的问题
break与continue超详解!!!
来 TDengine 开发者大会,洞悉数据技术发展的未来趋势
A Survey of Multi-Label Classification under Supervised and Semi-Supervised Learning
200PLC转以太网与研华webaccess modbusTCP客户端在空调机上应用配置案例
从数学角度和编码角度解释 熵、交叉熵、KL散度
【目标检测】yolov3特征提取网络------Darknet53网络及pytorch实现
随机推荐
SchedulX V1.5.0发布,提供快速压测、对象存储等全新功能!
Programmer Qixi Gift - How to quickly build an exclusive chat room for your girlfriend in 30 minutes
抗积分饱和PID控制器
yolo系列的Neck模块
全面认识MOS管,一篇文章就够了
UMA & Hong Kong Polytechnic & Ali propose SP-ViT to learn 2D space prior knowledge for visual Transformer!
backbone核心详解系列——RepVGG
systemdd-dev病毒杀
移动跨端技术方案分析对比
Focus!2022 interview must brush 461 interview questions summary + interview + resume template
JS逆向字体反爬,某供应商平台反爬实践
OAuth2图文快速入门
IBM Q复制ALTER ADD COLUMN
UMA&港理工&阿里提出SP-ViT,为视觉Transformer学习2D空间先验知识!
博云入选 Gartner 中国 DevOps 代表厂商
缓存字符流
年轻人为什么不喜欢买蒙牛、伊利了?
Flutter使用 json_serializable 解析 JSON 最佳方案
MySQL必知必会(初级篇)
num_workers