使用map将字数组里的对象重新组装
2023-09-27 14:22:21 时间
变为数组 ["扬子","北京","上海海吉雅"]
// 注意点 map循环的时候 不能够有空的 否则回出问题哦.
var list= [{
"goodsNum": 583816,
"order_num": 0,
"sales": "扬子",
"volume": 0,
"weight": 0
}, null ];
这样会报错
list=[{ "goodsNum": 583816, "order_num": 0, "sales": "扬子", "volume": 0, "weight": 0 }, { "goodsNum": 26484, "order_num": 0, "sales": "北京", "volume": 0, "weight": 0 }, { "goodsNum": 24403, "order_num": 0, "sales": "上海", "volume": 0, "weight": 0 }], let newarr=list.map(obj=>{ return obj.sales }) console.log(newarr) // ["扬子","北京","上海"]
相关文章
- MapReduce作业的map task和reduce task调度参数
- 往redis里存对象,将bean存入redis hash中,附Bean Map互转工具类
- MessagePack Java 0.6.X List, Map 对象的序列化和反序列化
- python lambda表达式&map/filter/reduce
- spring 3配置文件中如何注入map list set等类型
- PRJ: Split a nodes-map into some triangles
- google/dense_hash_map
- Java Map 简介
- jQuery 遍历 - map() 方法使用【转】
- list、map、对象对应json的格式
- 使用Java对轨迹进行抽稀,并生成mvt(Map Vector Tile)瓦片
- dreamweaver中的 map怎么调用?_制作热点图像区域
- A query was run and no Result Maps were found for the Mapped Statement 'user.insertUser!selectKey'. It's likely that neither a Result Type nor a Result Map was specified.
- hadoop编程小技巧(1)---map端聚合
- map的遍历
- STL中map用法详解
- 数据访问模式:Identity Map(标识映射)模式
- 大数据必学语言Scala(十八):基础语法学习 Map对象
- Java集合框架--List、Set、Map
- Java中如何遍历Map对象