Javascript根据另一个对象数组查找并替换嵌套的对象数组

我有两个数组:尝试使用find-and包实现这一点,但是没有运气。

arr1:

 [
      {
        id: 'awdaw21',
        menuItems: [
          {
            id: 'CrnSPBcPyErbAOa0nPLt'
          },
          {
            id: 'ibMCRkiyMrIqZdzDVGIa'
          }
        ]
      },
      {
        id: 'dw2gb72',
        menuItems: [
          {
            id: 'SDGNVomXMH92WVxZYDhf'
          }
        ]
      }
    ]

arr2:

[
    {
      title: 'lorem',
      content: [],
      id: 'CrnSPBcPyErbAOa0nPLt'
    },
    {
      title: 'impsum',
      content: [],
      id: 'SDGNVomXMH92WVxZYDhf'
    },
    {
      title: 'dolor',
      content: [],
      id: 'ibMCRkiyMrIqZdzDVGIa'
    }
  ]

我希望将arr1替换为arr2对象,结果想看到的是这样:从arr2的所有对象属性都移到了arr1

[     {       id:“ awdaw21”,       menuItems:[         {           id:“ CrnSPBcPyErbAOa0nPLt”,           标题:“ lorem”,           内容:[]         },         {           id:“ ibMCRkiyMrIqZdzDVGIa”,           标题:“ dolor”,           内容:[]         }       ]     },     {       id:“ dw2gb72”,       menuItems:[         {           id:“ SDGNVomXMH92WVxZYDhf”,           标题:“临时”,           内容:[]         }       ]     }   ]

评论