【发布时间】:2022-11-19 11:52:39
【问题描述】:
我正在尝试创建一个与我的输入类似的新对象,但仅包含所选 ID 列表中的元素。
const arrObj = [
{
value = 1,
name = 'a'
},
{
value = 2,
name = 'e'
},
{
value = 3,
name = 'i'
},
{
value = 4,
name = 'o'
},
{
value = 5,
name = 'u'
},
];
const selectedIds = [1,4,5];
// How can I make this selectedObjs as the same type as arrObj, but only containing the selected elements?
const selectedObjs = [];
【问题讨论】:
-
你尝试了什么?
标签: javascript arrays object