从对象数组中筛选符合条件的值
程序员文章站
2022-07-04 12:22:31
...
const arr = [1,2,3,4,5,6,7]
const list = [
{openId: 1, timelineId: 1, showNo: 1, uid: 1},
{openId: 2, timelineId: 1, showNo: 1, uid: 1},
{openId: 9, timelineId: 1, showNo: 1, uid: 1},
{openId: 4, timelineId: 1, showNo: 1, uid: 1},
{openId: 5, timelineId: 1, showNo: 1, uid: 1}
]
const params = list.filter(item=> arr.indexOf(item.openId) > -1)
console.log(params)