Answers for "compare and filter two array of object"

1

compare and filter two array of object

array1 = [{path: "hello"}, {path: "world"}];
array2 = [{path: "hello"}, {path: "hahah", text: "dsdsds"}];

//comparing array1 and array2 and returning unmatced from array1

Object.keys(array1)
  .filter((val, index) => array1[index].path !== array2[index].path)
  .map((val, index) => array1[index]);

// output
//[{"path": "world"}]
Posted by: Guest on September-23-2021

Code answers related to "compare and filter two array of object"

Code answers related to "Javascript"

Browse Popular Code Answers by Language