码迷,mamicode.com
首页 > 编程语言 > 详细

使用map将字数组里的对象重新组装

时间:2019-09-15 10:27:20      阅读:86      评论:0      收藏:0      [点我收藏+]

标签:volume   使用   asc   var   否则   数组   war   map   vol   

变为数组  ["扬子","北京","上海海吉雅"]

// 注意点 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) // ["扬子","北京","上海"]

  

使用map将字数组里的对象重新组装

标签:volume   使用   asc   var   否则   数组   war   map   vol   

原文地址:https://www.cnblogs.com/IwishIcould/p/11521199.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!