gpt4 book ai didi

javascript - 如何从对象数组中获取 id 并创建数组

转载 作者:行者123 更新时间:2023-12-03 00:02:39 25 4
gpt4 key购买 nike

var arrayOfObj = [{id: 41, uid: "62d0e9d5-25d4"},
{id: 42, uid: "62d0e9d5-25d4},
{id: 43, uid: "62d0e9d5-25d4},
{id: 44, uid: "62d0e9d5-25d4}];

预期结果:a= [41,42,43];

最佳答案

Array#map一起使用

arrayOfObj.map(a=>a.id)

关于javascript - 如何从对象数组中获取 id 并创建数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55107041/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com