猿问

js数组转对象

var a = [
"dwadmin",
"rladmin",
"ypadmin",
"ocradmin",
"admin",
"cvadmin"
]
转为
var b =[
{ "value": "dwadmin"},
{ "value": "rladmin"},
{ "value": "ocradmin"},
{ "value": "admin"},
{ "value": "cvadmin"},
{ "value": "dwadmin"},
];

慕田峪9158850
浏览 559回答 2
2回答

HUH函数

var res = a.map(item => {  return {value: item} })

慕桂英546537

这种问题也有人抢着答吗?不是应该踩一下吗?
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答