欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

从对象数组中筛选符合条件的值

程序员文章站 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)

从对象数组中筛选符合条件的值
从对象数组中筛选符合条件的值