Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

intersection array of object javascript

let data = [
    {
      id: "1",
      name: "test"
    },
    {
      id: "2",
      name: "test"
    }
  ];
  let data2 = [
    {
      id: "1",
      name: "test"
    },
    {
      id: "3",
      name: "test"
    }
  ];
  const result = data.filter((a) => data2.some((b) => a.id === b.id));
  console.log(result);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #intersection #array #object #javascript
ADD COMMENT
Topic
Name
4+6 =