Answers for "check if lists have intersection javascript"

2

js array intersection object

const arr1 = [{ id: 1 }, { id: 2 }]
const arr2 = [{ id: 1 }, { id: 3 }]
const intersection = arr1.filter(item1 => arr2.some(item2 => item1.id === item2.id))
// intersection => [{ id: 1 }]
Posted by: Guest on July-31-2020

Code answers related to "check if lists have intersection javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language