博客
关于我
再返回结果的数组对象里面添加一个新的字段
阅读量:680 次
发布时间:2019-03-17

本文共 400 字,大约阅读时间需要 1 分钟。

var arry = [{a:11,b:22,c:33,d:44},{a:11,b:0,c:0,d:44},{a:11,b:22,c:99,d:99}];var arry2 = [];arry.map((item, index) => {    arry2.push(Object.assign({}, item, {mess1: item.c, mess2: item.d}));});console.log(arry2);

通过上述代码,可以看到数组字段的值会被合并到新的对象中。通过map函数将原数组中的对象逐一处理,生成包含附加字段mess1和mess2的新对象列表。最终将处理结果输出。该方法通过单纯的赋值操作实现字段的扩展,符合数据操作的业务需求。

原文链接:https://blog.csdn.net/qq_24147051/article/details/80541112

你可能感兴趣的文章
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named 'pandads'
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>
No new migrations found. Your system is up-to-date.
查看>>
No qualifying bean of type XXX found for dependency XXX.
查看>>