当前位置:网站首页>JS array object to object
JS array object to object
2022-06-25 01:44:00 【Э Time walker to me】
Convert the data of an array object into a normal object key value pair key:value In the form of

let arr = [
{
id:'1',employeeNo:'110',name:' Zhang San '},
{
id:'2',employeeNo:'111',name:' Li Si '},
{
id:'3',employeeNo:'112',name:' Wang Wu '},
{
id:'4',employeeNo:'113',name:' Zhang Yu '},
{
id:'5',employeeNo:'114',name:' Xiaohong '},
]
let newObj = {
}
arr.map(item => {
newObj[item.employeeNo] = item.name // It can be spliced according to your own needs
})
console.log(newObj) // {110: ' Zhang San ', 111: ' Li Si ', 112: ' Wang Wu ', 113: ' Zhang Yu ', 114: ' Xiaohong '}
console.log(newObj[112]) // ' Wang Wu '
边栏推荐
- TC对象结构和简称
- Experiment 5 8254 timing / counter application experiment [microcomputer principle] [experiment]
- 数组中关于sizeof()和strlen
- Some Modest Advice for Graduate Students - by Stephen C. Stearns, Ph.D.
- Audio PCM data calculates sound decibel value to realize simple VAD function
- void* 指针
- Linux64Bit下安装MySQL5.6-不能修改root密码
- PHP 利用getid3 获取mp3、mp4、wav等媒体文件时长等数据
- 修身励学篇
- 屡获大奖的界面控件开发包DevExpress v22.1官宣发布
猜你喜欢
随机推荐
Is CICC securities reliable? Is it safe to open a securities account?
(CVPR 2020) Learning Object Bounding Boxes for 3D Instance Segmentation on Point Clouds
Huawei laptop, which grew against the trend in Q1, is leading PC into the era of "smart office"
Use redis' sorted set to make weekly hot Reviews
1. package your own scaffold 2 Create code module
Q1季度逆势增长的华为笔电,正引领PC进入“智慧办公”时代
谷歌浏览器控制台 f12怎么设置成中文/英文 切换方法,一定要看到最后!!!
实验5 8254定时/计数器应用实验【微机原理】【实验】
js数组对象转对象
天书夜读笔记——8.4 diskperf反汇编
‘distutils‘ has no attribute ‘version
Transformers 库的基本使用
Tianshu night reading notes -- disassembly engine xde32
全排列II[存在相同元素去重 + 标准回溯]
sql 聚合函数有哪些
百度语音合成语音文件并在网站中展示
粉丝福利,JVM 手册(包含 PDF)
Numerical scheme simulation of forward stochastic differential equations with Markov Switching
海河实验室创新联合体成立 GBASE成为首批创新联合体(信创)成员单位
Assembly language (3) 16 bit assembly basic framework and addition and subtraction loop

![Search two-dimensional matrix [clever use of bisection + record solution different from inserting bisection]](/img/c9/afc03afd477bbfdd3c0dc54bacfd2d.png)







