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

Posted iwishicould

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用map将字数组里的对象重新组装相关的知识,希望对你有一定的参考价值。

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

// 注意点 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将字数组里的对象重新组装的主要内容,如果未能解决你的问题,请参考以下文章