I have an array
let idarray = [55, 25, 24]
and another array
let details = [
{id:55, name:"GHN"},
{id:46, name:"GTN"},
{id:78, name:"AHN"},
]
I want to filter the object which has id in details aray equal to idarray.How to filter
>Solution :
let idarray = [55, 25, 24]
let details = [
{id:55, name:"GHN"},
{id:46, name:"GTN"},
{id:78, name:"AHN"},
]
const result = details.filter(item => {
return idarray.includes(item.id)
})
as the comments suggested includes and filters should do it