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

Bi SQL alias

实验5 8254定时/计数器应用实验【微机原理】【实验】

Application session coverage solutions with different ports on the same server

void* 指针

AutoCAD - two extension modes

(CVPR 2020) Learning Object Bounding Boxes for 3D Instance Segmentation on Point Clouds

Bi SQL drop & alter

Hands on data analysis data modeling and model evaluation

Bi SQL constraints

Google browser console F12 how to set the Chinese / English switching method, we must see the last!!!
随机推荐
PS5连接OPPO K9电视不支持2160P/4K
MySQL gets the primary key and table structure of the table
Assembly language (3) 16 bit assembly basic framework and addition and subtraction loop
Chinese and English instructions of trypsin
Tianshu night reading notes -- disassembly engine xde32
Some Modest Advice for Graduate Students - by Stephen C. Stearns, Ph.D.
[leetcode] 11. Container with the most water
"One good programmer is worth five ordinary programmers!"
AUTOCAD——两种延伸方式
Redis and jedis
Abnova丨5-甲基胞嘧啶多克隆抗体中英文说明
Unity C # e-learning (VI) -- FTP (I)
第04天-文件IO
JVM directive
修身励学篇
Tencent cloud wecity Industry joint collaborative innovation to celebrate the New Year!
监听 Markdown 文件并热更新 Next.js 页面
百度语音合成语音文件并在网站中展示
Tencent has completed the comprehensive cloud launch to build the largest cloud native practice in China
uni-app集成极光推送插件后真机调试提示“当前运行的基座不包含原生插件[JG-JPush]...”问题的解决办法