当前位置:网站首页>js数组对象转对象
js数组对象转对象
2022-06-24 21:07:00 【Э时间行者于我】
将数组对象的数据转换为普通对象键值对key:value的形式

let arr = [
{
id:'1',employeeNo:'110',name:'张三'},
{
id:'2',employeeNo:'111',name:'李四'},
{
id:'3',employeeNo:'112',name:'王五'},
{
id:'4',employeeNo:'113',name:'章雨'},
{
id:'5',employeeNo:'114',name:'小红'},
]
let newObj = {
}
arr.map(item => {
newObj[item.employeeNo] = item.name // 根据自己需求可以拼接
})
console.log(newObj) // {110: '张三', 111: '李四', 112: '王五', 113: '章雨', 114: '小红'}
console.log(newObj[112]) // '王五'
边栏推荐
猜你喜欢

Ideas and examples of divide and conquer

Bi-sql - different join

丹麦技术大学首创将量子计算应用于能源系统潮流建模

Bi-sql index

2种常见的设备稼动率OEE监测方法

程序员:是花光积蓄在深圳买房?还是回到长沙过“富余”生活?

1. package your own scaffold 2 Create code module

Danish Technical University pioneered the application of quantum computing to power flow modeling of energy system

Abnova丨BSG 单克隆抗体中英文说明

实验5 8254定时/计数器应用实验【微机原理】【实验】
随机推荐
“一个优秀程序员可抵五个普通程序员!”
Ideas and examples of divide and conquer
Powerbi - for you who are learning
Fan benefits, JVM manual (including PDF)
This national day! Tencent cloud wecity will accompany you to travel and light up the city landmark
How about compass stock trading software? Is it safe?
Convert MySQL query timestamp to date format
What to learn in VB [easy to understand]
Boutique enterprise class powerbi application pipeline deployment
卷积与反卷积关系超详细说明及推导(反卷积又称转置卷积、分数步长卷积)
【直播回顾】2022腾讯云未来社区城市运营方招募会暨SaaS 2.0新品发布会!
4 years of working experience, and you can't tell the five communication modes between multithreads. Can you believe it?
Lenovo tongfuyao: 11 times the general trend, we attacked the city and pulled out the stronghold all the way
Linux64Bit下安装MySQL5.6-不能修改root密码
Assembly language (4) function transfer parameters
Golang example renewal lock: redis+channel+sync Mutex
图片旋转移动缩放渐变
Program.launch(xxx)打开文件
用手机在同花顺上开户靠谱吗?这样炒股有没有什么安全隐患
JS Chapter 1 Summary