📌  相关文章
📜  比较和过滤两个对象数组 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:38.458000             🧑  作者: Mango

代码示例1
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"}]