I need to get filtrated array that have products only with ids from first array. I tried something like this:
let first = [1, 4]
let second = [{id: 1}, {id: 2}, {id: 4}]
second.filter((es, i) => es.id.includes(first))
I need to get filtrated array that have products only with ids from first array. I tried something like this:
let first = [1, 4]
let second = [{id: 1}, {id: 2}, {id: 4}]
second.filter((es, i) => es.id.includes(first))
you will need to reverse the include condition so it should be first.includes(es.id)
instead of es.id.includes(first)
let first = [1, 4]
let second = [{id: 1}, {id: 2}, {id: 4}]
let result=second.filter(es => first.includes(es.id))
console.log(result);