compare and filter two array of object

Solutions on MaxInterview for compare and filter two array of object by the best coders in the world

showing results for - "compare and filter two array of object"
Ricardo
24 Jan 2020
1array1 = [{path: "hello"}, {path: "world"}];
2array2 = [{path: "hello"}, {path: "hahah", text: "dsdsds"}];
3
4//comparing array1 and array2 and returning unmatced from array1
5
6Object.keys(array1)
7  .filter((val, index) => array1[index].path !== array2[index].path)
8  .map((val, index) => array1[index]);
9
10// output
11//[{"path": "world"}]