我有一个“列表”数组
let list = [
{
advance_amount: "100"
id: "SUBMH9876"
created_by: "12346"
created_date: "Thu, 08 Nov 2018 11:23:00 GMT"
},
{
advance_amount: "200"
id: "SUBIH9876"
created_by: "12346"
created_date: "Thu, 08 Nov 2018 11:23:00 GMT"
}
]
我想从上面的数组中推入另一个数组,例如下面的格式
let subarray = [
{id: "SUBMH9876"},
{id: "SUBIH9876"}
]
我尝试如下:
var subarray = list .map(function (el) { return el.id; });
但是只有值显示在数组中
答案 0 :(得分:2)
let list = [{
advance_amount: "100",
id: "SUBMH9876",
created_by: "12346",
created_date: "Thu, 08 Nov 2018 11:23:00 GMT"
},
{
advance_amount: "200",
id: "SUBIH9876",
created_by: "12346",
created_date: "Thu, 08 Nov 2018 11:23:00 GMT"
}
];
var subArr = list.map((item) => {
return { id: item.id }
});
console.log(subArr)
答案 1 :(得分:0)
这可以做到
.git/objects/12/34567...