当前位置:网站首页>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]) // '王五'
边栏推荐
猜你喜欢

Linux64Bit下安装MySQL5.6-不能修改root密码

4年工作经验,多线程间的5种通信方式都说不出来,你敢信?

How to store dataframe data in pandas into MySQL

Fan benefits, JVM manual (including PDF)

百度语音合成语音文件并在网站中展示

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

Powerbi - for you who are learning

利用 Redis 的 sorted set 做每周热评的功能

1. 封装自己的脚手架 2.创建代码模块

Using macro code to generate handwriting automatically in word or WPS
随机推荐
Bi-sql - different join
php easywechat 和 小程序 实现 长久订阅消息推送
"One good programmer is worth five ordinary programmers!"
ImageView展示网络图片
Which securities company should I choose to open an account online? Is it safe to open an account online?
lnmp环境安装ffmpeg,并在Yii2中使用
The latest QQ wechat domain name anti red PHP program source code + forced jump to open
Tianshu night reading notes -- memory paging mechanism
C语言边界计算和不对称边界
归并排序模板 & 理解
Go language operators (under Lesson 8)
MySQL gets the primary key and table structure of the table
新一代可级联的以太网远程I/O数据采集模块
VB learning notes
MySQL common basic statements (collation)
C language boundary calculation and asymmetric boundary
Assembly language (4) function transfer parameters
汇编语言(2)基础知识-debug
天书夜读笔记——深入虚函数virtual
梦想CAD云图与GIS结合演示