js提取对象数组中某个属性并组成新的数组
作者:互联网
例如:
info = [
{STAFF_NAME: "1",USERNAME: "a"},
{STAFF_NAME: "2",USERNAME: "b"}
{STAFF_NAME: "3",USERNAME: "c"}
{STAFF_NAME: "4",USERNAME: "d"}
{STAFF_NAME: "5",USERNAME: "e"}
]
方法一:
info.forEach(e => {
arrnew.push(e.STAFF_NAME) })
方法二:
let arrnew = info.amp(obj=>{
return obj.STAFF_NAME
)
标签:USERNAME,info,obj,NAME,js,数组,arrnew,STAFF,属性 来源: https://www.cnblogs.com/tianz/p/15697474.html