Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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 }]
 
PREVIOUS NEXT
Tagged: #js #array #intersection #object
ADD COMMENT
Topic
Name
3+2 =