赞
踩
代码如下(示例):
let arr1= [18, 24];
let arr2= [
{id: '1', name: '张三', age: 18},
{id: '2', name: '李四', age: 30},
{id: '3', name: '王五', age: 24},
{id: '4', name: '赵六', age: 18},
];
let result = arr2.filter((item)=>{
return arr1.some(curVal => (curVal === item.age))
})
// console.log(result)
运行结果如下:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。