将对象数组与嵌套对象数组进行比较,并获取无与伦比的对象数组

发布于 2025-01-20 20:33:08 字数 6365 浏览 0 评论 0原文

    const A = [
      {
        campaignId: "3964126695264",
        portfolioData: {
          portfolioData: [
            {
              asin: "B08FHG17ZH",
              sku: ["130511"],
            },
            {
              asin: "B08FHF74TB",
              sku: ["130512"],
            },
            {
              asin: "B08FHBWP89",
              sku: ["130513"],
            },
            {
              asin: "B08FHFL6GD",
              sku: ["130514"],
            },
            {
              asin: "B08FHDWTK2",
              sku: ["130515"],
            },
            {
              asin: "B08FHFMW1V",
              sku: ["130516"],
            },
            {
              asin: "B08FHF6V8B",
              sku: ["130517"],
            },
            {
              asin: "B08FHFWDVM",
              sku: ["130518"],
            },
            {
              asin: "B08FHFD18R",
              sku: ["130519"],
            },
            {
              asin: "B08JKK4217",
              sku: ["130520"],
            },
            {
              asin: "B08JKP82PB",
              sku: ["130521"],
            },
          ],
        },
      },
      {
        campaignId: "137244687845173",
        portfolioData: {
          portfolioData: [
            {
              asin: "B08FHG17ZH",
              sku: ["130511"],
            },
            {
              asin: "B08FHF74TB",
              sku: ["130512"],
            },
            {
              asin: "B08FHBWP89",
              sku: ["130513"],
            },
            {
              asin: "B08FHFL6GD",
              sku: ["130514"],
            },
            {
              asin: "B08FHDWTK2",
              sku: ["130515"],
            },
            {
              asin: "B08FHFMW1V",
              sku: ["130516"],
            },
            {
              asin: "B08FHF6V8B",
              sku: ["130517"],
            },
            {
              asin: "B08FHFWDVM",
              sku: ["130518"],
            },
            {
              asin: "B08FHFD18R",
              sku: ["130519"],
            },
            {
              asin: "B08JKK4217",
              sku: ["130520"],
            },
            {
              asin: "B08JKP82PB",
              sku: ["130521"],
            },
          ],
        },
      },
      {
        campaignId: "182862063246935",
        portfolioData: {
          portfolioData: [
            {
              asin: "B08FHG17ZH",
              sku: ["130511"],
            },
            {
              asin: "B08FHF74TB",
              sku: ["130512"],
            },
            {
              asin: "B08FHBWP89",
              sku: ["130513"],
            },
            {
              asin: "B08FHFL6GD",
              sku: ["130514"],
            },
            {
              asin: "B08FHDWTK2",
              sku: ["130515"],
            },
            {
              asin: "B08FHFMW1V",
              sku: ["130516"],
            },
            {
              asin: "B08FHF6V8B",
              sku: ["130517"],
            },
            {
              asin: "B08FHFWDVM",
              sku: ["130518"],
            },
            {
              asin: "B08FHFD18R",
              sku: ["130519"],
            },
            {
              asin: "B08JKK4217",
              sku: ["130520"],
            },
            {
              asin: "B08JKP82PB",
              sku: ["130521"],
            },
          ],
        },
      },
      {
        campaignId: "262747542546680",
        portfolioData: {
          portfolioData: [
            {
              asin: "B08FHG17ZH",
              sku: ["130511"],
            },
            {
              asin: "B08FHF74TB",
              sku: ["130512"],
            },
            {
              asin: "B08FHBWP89",
              sku: ["130513"],
            },
            {
              asin: "B08FHFL6GD",
              sku: ["130514"],
            },
            {
              asin: "B08FHDWTK2",
              sku: ["130515"],
            },
            {
              asin: "B08FHFMW1V",
              sku: ["130516"],
            },
            {
              asin: "B08FHF6V8B",
              sku: ["130517"],
            },
            {
              asin: "B08FHFWDVM",
              sku: ["130518"],
            },
            {
              asin: "B08FHFD18R",
              sku: ["130519"],
            },
            {
              asin: "B08JKK4217",
              sku: ["130520"],
            },
            {
              asin: "B08JKP82PB",
              sku: ["130521"],
            },
          ],
        },
      },
    ];

    const B = {
      ProductMetadataList: [
        {
          asin: "B08FHG17ZH",
          sku: "130511"
        },
        {
          asin: "B08FHF74TB",
          sku: "130512"
        },
        {
          asin: "B08FHBWP89",
          sku: "130513"
        },
        {
          asin: "B08FHFL6GD",
          sku: "130514"
        },
        {
          asin: "B08FHDWTK2",
          sku: "130515"
        },
        {
          asin: "B08FHFMW1V",
          sku: "130516"
        },
        {
          asin: "B08FHF6V8B",
          sku: "130517"
        },
        {
          asin: "B08FHFWDVM",
          sku: "130518"
        },
        {
          asin: "B08FHFD18R",
          sku: "130519"
        },
        {
          asin: "B08JKK4217",
          sku: "130520"
        },
        {
          asin: "B08JKP82PB",
          sku: "130521"
        },
        {
          asin: "B08JKP82PB",
          sku: "13052221"
        },
      ],
    };

        let difference = B.ProductMetadataList.filter((page1) => {
      const result = A.forEach((element) => {
        element.portfolioData.portfolioData.find((page2) => {
          if (page1.asin === page2.asin) {
            page2.sku.includes(page1.sku);
          }
        });
      });
      return !result;
    });
    
    console.log("difference check ", difference);

由于page1.asin === page2.asin不匹配您可以console.log(page1.asin ==== page2.asin)不匹配,因此无法实现上述结果。并了解我无法解释的差异。

我正在尝试实现: - 将B数组与数组进行比较,并从数组B中获取无与伦比的对象。

困难: - 无法从数组B -SKU值中检查阵列A -SKU数组中是否存在该值。

    const A = [
      {
        campaignId: "3964126695264",
        portfolioData: {
          portfolioData: [
            {
              asin: "B08FHG17ZH",
              sku: ["130511"],
            },
            {
              asin: "B08FHF74TB",
              sku: ["130512"],
            },
            {
              asin: "B08FHBWP89",
              sku: ["130513"],
            },
            {
              asin: "B08FHFL6GD",
              sku: ["130514"],
            },
            {
              asin: "B08FHDWTK2",
              sku: ["130515"],
            },
            {
              asin: "B08FHFMW1V",
              sku: ["130516"],
            },
            {
              asin: "B08FHF6V8B",
              sku: ["130517"],
            },
            {
              asin: "B08FHFWDVM",
              sku: ["130518"],
            },
            {
              asin: "B08FHFD18R",
              sku: ["130519"],
            },
            {
              asin: "B08JKK4217",
              sku: ["130520"],
            },
            {
              asin: "B08JKP82PB",
              sku: ["130521"],
            },
          ],
        },
      },
      {
        campaignId: "137244687845173",
        portfolioData: {
          portfolioData: [
            {
              asin: "B08FHG17ZH",
              sku: ["130511"],
            },
            {
              asin: "B08FHF74TB",
              sku: ["130512"],
            },
            {
              asin: "B08FHBWP89",
              sku: ["130513"],
            },
            {
              asin: "B08FHFL6GD",
              sku: ["130514"],
            },
            {
              asin: "B08FHDWTK2",
              sku: ["130515"],
            },
            {
              asin: "B08FHFMW1V",
              sku: ["130516"],
            },
            {
              asin: "B08FHF6V8B",
              sku: ["130517"],
            },
            {
              asin: "B08FHFWDVM",
              sku: ["130518"],
            },
            {
              asin: "B08FHFD18R",
              sku: ["130519"],
            },
            {
              asin: "B08JKK4217",
              sku: ["130520"],
            },
            {
              asin: "B08JKP82PB",
              sku: ["130521"],
            },
          ],
        },
      },
      {
        campaignId: "182862063246935",
        portfolioData: {
          portfolioData: [
            {
              asin: "B08FHG17ZH",
              sku: ["130511"],
            },
            {
              asin: "B08FHF74TB",
              sku: ["130512"],
            },
            {
              asin: "B08FHBWP89",
              sku: ["130513"],
            },
            {
              asin: "B08FHFL6GD",
              sku: ["130514"],
            },
            {
              asin: "B08FHDWTK2",
              sku: ["130515"],
            },
            {
              asin: "B08FHFMW1V",
              sku: ["130516"],
            },
            {
              asin: "B08FHF6V8B",
              sku: ["130517"],
            },
            {
              asin: "B08FHFWDVM",
              sku: ["130518"],
            },
            {
              asin: "B08FHFD18R",
              sku: ["130519"],
            },
            {
              asin: "B08JKK4217",
              sku: ["130520"],
            },
            {
              asin: "B08JKP82PB",
              sku: ["130521"],
            },
          ],
        },
      },
      {
        campaignId: "262747542546680",
        portfolioData: {
          portfolioData: [
            {
              asin: "B08FHG17ZH",
              sku: ["130511"],
            },
            {
              asin: "B08FHF74TB",
              sku: ["130512"],
            },
            {
              asin: "B08FHBWP89",
              sku: ["130513"],
            },
            {
              asin: "B08FHFL6GD",
              sku: ["130514"],
            },
            {
              asin: "B08FHDWTK2",
              sku: ["130515"],
            },
            {
              asin: "B08FHFMW1V",
              sku: ["130516"],
            },
            {
              asin: "B08FHF6V8B",
              sku: ["130517"],
            },
            {
              asin: "B08FHFWDVM",
              sku: ["130518"],
            },
            {
              asin: "B08FHFD18R",
              sku: ["130519"],
            },
            {
              asin: "B08JKK4217",
              sku: ["130520"],
            },
            {
              asin: "B08JKP82PB",
              sku: ["130521"],
            },
          ],
        },
      },
    ];

    const B = {
      ProductMetadataList: [
        {
          asin: "B08FHG17ZH",
          sku: "130511"
        },
        {
          asin: "B08FHF74TB",
          sku: "130512"
        },
        {
          asin: "B08FHBWP89",
          sku: "130513"
        },
        {
          asin: "B08FHFL6GD",
          sku: "130514"
        },
        {
          asin: "B08FHDWTK2",
          sku: "130515"
        },
        {
          asin: "B08FHFMW1V",
          sku: "130516"
        },
        {
          asin: "B08FHF6V8B",
          sku: "130517"
        },
        {
          asin: "B08FHFWDVM",
          sku: "130518"
        },
        {
          asin: "B08FHFD18R",
          sku: "130519"
        },
        {
          asin: "B08JKK4217",
          sku: "130520"
        },
        {
          asin: "B08JKP82PB",
          sku: "130521"
        },
        {
          asin: "B08JKP82PB",
          sku: "13052221"
        },
      ],
    };

        let difference = B.ProductMetadataList.filter((page1) => {
      const result = A.forEach((element) => {
        element.portfolioData.portfolioData.find((page2) => {
          if (page1.asin === page2.asin) {
            page2.sku.includes(page1.sku);
          }
        });
      });
      return !result;
    });
    
    console.log("difference check ", difference);

Not able to achieve above result because the page1.asin === page2.asin is not matching you can console.log(page1.asin === page2.asin) and understand the difference as i am not able to explian.

I am trying to achieve:-
Comparing B array to A array and getting unmatched objects from array B.

Difficulties faicing:-
Not able to check if the value is present in array A - sku array from array B - sku value.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

往昔成烟 2025-01-27 20:33:08

只有2行

  • 制作一个阵列一个级别数组 - 更容易找到匹配项
    a.map(i => i.portfoliodata.portfoliodata).flat();

  • 找到元素
    b。构成元素师.filter(i =>!assinlista.find(j => i.asin ==== j.asin&&& j.sku.includes(i.sku)))


const A = [
  {
    campaignId: "3964126695264",
    portfolioData: {
      portfolioData: [
        {
          asin: "B08FHG17ZH",
          sku: ["130511"],
        },
        {
          asin: "B08FHF74TB",
          sku: ["130512"],
        },
        {
          asin: "B08FHBWP89",
          sku: ["130513"],
        },
        {
          asin: "B08FHFL6GD",
          sku: ["130514"],
        },
        {
          asin: "B08FHDWTK2",
          sku: ["130515"],
        },
        {
          asin: "B08FHFMW1V",
          sku: ["130516"],
        },
        {
          asin: "B08FHF6V8B",
          sku: ["130517"],
        },
        {
          asin: "B08FHFWDVM",
          sku: ["130518"],
        },
        {
          asin: "B08FHFD18R",
          sku: ["130519"],
        },
        {
          asin: "B08JKK4217",
          sku: ["130520"],
        },
        {
          asin: "B08JKP82PB",
          sku: ["130521"],
        },
      ],
    },
  },
  {
    campaignId: "137244687845173",
    portfolioData: {
      portfolioData: [
        {
          asin: "B08FHG17ZH",
          sku: ["130511"],
        },
        {
          asin: "B08FHF74TB",
          sku: ["130512"],
        },
        {
          asin: "B08FHBWP89",
          sku: ["130513"],
        },
        {
          asin: "B08FHFL6GD",
          sku: ["130514"],
        },
        {
          asin: "B08FHDWTK2",
          sku: ["130515"],
        },
        {
          asin: "B08FHFMW1V",
          sku: ["130516"],
        },
        {
          asin: "B08FHF6V8B",
          sku: ["130517"],
        },
        {
          asin: "B08FHFWDVM",
          sku: ["130518"],
        },
        {
          asin: "B08FHFD18R",
          sku: ["130519"],
        },
        {
          asin: "B08JKK4217",
          sku: ["130520"],
        },
        {
          asin: "B08JKP82PB",
          sku: ["130521"],
        },
      ],
    },
  },
  {
    campaignId: "182862063246935",
    portfolioData: {
      portfolioData: [
        {
          asin: "B08FHG17ZH",
          sku: ["130511"],
        },
        {
          asin: "B08FHF74TB",
          sku: ["130512"],
        },
        {
          asin: "B08FHBWP89",
          sku: ["130513"],
        },
        {
          asin: "B08FHFL6GD",
          sku: ["130514"],
        },
        {
          asin: "B08FHDWTK2",
          sku: ["130515"],
        },
        {
          asin: "B08FHFMW1V",
          sku: ["130516"],
        },
        {
          asin: "B08FHF6V8B",
          sku: ["130517"],
        },
        {
          asin: "B08FHFWDVM",
          sku: ["130518"],
        },
        {
          asin: "B08FHFD18R",
          sku: ["130519"],
        },
        {
          asin: "B08JKK4217",
          sku: ["130520"],
        },
        {
          asin: "B08JKP82PB",
          sku: ["130521"],
        },
      ],
    },
  },
  {
    campaignId: "262747542546680",
    portfolioData: {
      portfolioData: [
        {
          asin: "B08FHG17ZH",
          sku: ["130511"],
        },
        {
          asin: "B08FHF74TB",
          sku: ["130512"],
        },
        {
          asin: "B08FHBWP89",
          sku: ["130513"],
        },
        {
          asin: "B08FHFL6GD",
          sku: ["130514"],
        },
        {
          asin: "B08FHDWTK2",
          sku: ["130515"],
        },
        {
          asin: "B08FHFMW1V",
          sku: ["130516"],
        },
        {
          asin: "B08FHF6V8B",
          sku: ["130517"],
        },
        {
          asin: "B08FHFWDVM",
          sku: ["130518"],
        },
        {
          asin: "B08FHFD18R",
          sku: ["130519"],
        },
        {
          asin: "B08JKK4217",
          sku: ["130520"],
        },
        {
          asin: "B08JKP82PB",
          sku: ["130521"],
        },
      ],
    },
  },
];

const B = {
  ProductMetadataList: [
    {
      asin: "B08FHG17ZH",
      sku: "130511"
    },
    {
      asin: "B08FHF74TB",
      sku: "130512"
    },
    {
      asin: "B08FHBWP89",
      sku: "130513"
    },
    {
      asin: "B08FHFL6GD",
      sku: "130514"
    },
    {
      asin: "B08FHDWTK2",
      sku: "130515"
    },
    {
      asin: "B08FHFMW1V",
      sku: "130516"
    },
    {
      asin: "B08FHF6V8B",
      sku: "130517"
    },
    {
      asin: "B08FHFWDVM",
      sku: "130518"
    },
    {
      asin: "B08FHFD18R",
      sku: "130519"
    },
    {
      asin: "B08JKK4217",
      sku: "130520"
    },
    {
      asin: "B08JKP82PB",
      sku: "130521"
    },
    {
      asin: "B08JKP82PB",
      sku: "13052221"
    },
  ],
};


const assinListA = A.map(i => i.portfolioData.portfolioData).flat();

const res = B.ProductMetadataList
.filter(i => !assinListA.find(j => i.asin === j.asin && j.sku.includes(i.sku)))

console.log(res)

just 2 lines

  • make A array one level array - it will be easier to find a match
    A.map(i => i.portfolioData.portfolioData).flat();

  • filter found element
    B.ProductMetadataList .filter(i => !assinListA.find(j => i.asin === j.asin && j.sku.includes(i.sku)))

const A = [
  {
    campaignId: "3964126695264",
    portfolioData: {
      portfolioData: [
        {
          asin: "B08FHG17ZH",
          sku: ["130511"],
        },
        {
          asin: "B08FHF74TB",
          sku: ["130512"],
        },
        {
          asin: "B08FHBWP89",
          sku: ["130513"],
        },
        {
          asin: "B08FHFL6GD",
          sku: ["130514"],
        },
        {
          asin: "B08FHDWTK2",
          sku: ["130515"],
        },
        {
          asin: "B08FHFMW1V",
          sku: ["130516"],
        },
        {
          asin: "B08FHF6V8B",
          sku: ["130517"],
        },
        {
          asin: "B08FHFWDVM",
          sku: ["130518"],
        },
        {
          asin: "B08FHFD18R",
          sku: ["130519"],
        },
        {
          asin: "B08JKK4217",
          sku: ["130520"],
        },
        {
          asin: "B08JKP82PB",
          sku: ["130521"],
        },
      ],
    },
  },
  {
    campaignId: "137244687845173",
    portfolioData: {
      portfolioData: [
        {
          asin: "B08FHG17ZH",
          sku: ["130511"],
        },
        {
          asin: "B08FHF74TB",
          sku: ["130512"],
        },
        {
          asin: "B08FHBWP89",
          sku: ["130513"],
        },
        {
          asin: "B08FHFL6GD",
          sku: ["130514"],
        },
        {
          asin: "B08FHDWTK2",
          sku: ["130515"],
        },
        {
          asin: "B08FHFMW1V",
          sku: ["130516"],
        },
        {
          asin: "B08FHF6V8B",
          sku: ["130517"],
        },
        {
          asin: "B08FHFWDVM",
          sku: ["130518"],
        },
        {
          asin: "B08FHFD18R",
          sku: ["130519"],
        },
        {
          asin: "B08JKK4217",
          sku: ["130520"],
        },
        {
          asin: "B08JKP82PB",
          sku: ["130521"],
        },
      ],
    },
  },
  {
    campaignId: "182862063246935",
    portfolioData: {
      portfolioData: [
        {
          asin: "B08FHG17ZH",
          sku: ["130511"],
        },
        {
          asin: "B08FHF74TB",
          sku: ["130512"],
        },
        {
          asin: "B08FHBWP89",
          sku: ["130513"],
        },
        {
          asin: "B08FHFL6GD",
          sku: ["130514"],
        },
        {
          asin: "B08FHDWTK2",
          sku: ["130515"],
        },
        {
          asin: "B08FHFMW1V",
          sku: ["130516"],
        },
        {
          asin: "B08FHF6V8B",
          sku: ["130517"],
        },
        {
          asin: "B08FHFWDVM",
          sku: ["130518"],
        },
        {
          asin: "B08FHFD18R",
          sku: ["130519"],
        },
        {
          asin: "B08JKK4217",
          sku: ["130520"],
        },
        {
          asin: "B08JKP82PB",
          sku: ["130521"],
        },
      ],
    },
  },
  {
    campaignId: "262747542546680",
    portfolioData: {
      portfolioData: [
        {
          asin: "B08FHG17ZH",
          sku: ["130511"],
        },
        {
          asin: "B08FHF74TB",
          sku: ["130512"],
        },
        {
          asin: "B08FHBWP89",
          sku: ["130513"],
        },
        {
          asin: "B08FHFL6GD",
          sku: ["130514"],
        },
        {
          asin: "B08FHDWTK2",
          sku: ["130515"],
        },
        {
          asin: "B08FHFMW1V",
          sku: ["130516"],
        },
        {
          asin: "B08FHF6V8B",
          sku: ["130517"],
        },
        {
          asin: "B08FHFWDVM",
          sku: ["130518"],
        },
        {
          asin: "B08FHFD18R",
          sku: ["130519"],
        },
        {
          asin: "B08JKK4217",
          sku: ["130520"],
        },
        {
          asin: "B08JKP82PB",
          sku: ["130521"],
        },
      ],
    },
  },
];

const B = {
  ProductMetadataList: [
    {
      asin: "B08FHG17ZH",
      sku: "130511"
    },
    {
      asin: "B08FHF74TB",
      sku: "130512"
    },
    {
      asin: "B08FHBWP89",
      sku: "130513"
    },
    {
      asin: "B08FHFL6GD",
      sku: "130514"
    },
    {
      asin: "B08FHDWTK2",
      sku: "130515"
    },
    {
      asin: "B08FHFMW1V",
      sku: "130516"
    },
    {
      asin: "B08FHF6V8B",
      sku: "130517"
    },
    {
      asin: "B08FHFWDVM",
      sku: "130518"
    },
    {
      asin: "B08FHFD18R",
      sku: "130519"
    },
    {
      asin: "B08JKK4217",
      sku: "130520"
    },
    {
      asin: "B08JKP82PB",
      sku: "130521"
    },
    {
      asin: "B08JKP82PB",
      sku: "13052221"
    },
  ],
};


const assinListA = A.map(i => i.portfolioData.portfolioData).flat();

const res = B.ProductMetadataList
.filter(i => !assinListA.find(j => i.asin === j.asin && j.sku.includes(i.sku)))

console.log(res)

假装爱人 2025-01-27 20:33:08

一种简单且易于阅读的方法是注册匹配数据的数组 B 的索引,然后通过这些索引进行过滤。

注意:我减少了数组以使代码更易于阅读。它将与您的数据一起使用。

const A = [
  { 
    campaignId: "3964126695264",
    portfolioData: { 
      portfolioData: [
        { asin: "B08JKK4217", sku: ["130520"]},
        { asin: "B08JKP82PB", sku: ["130521"]}
      ]
    }
  },
  { 
  campaignId: "137244687845173",
    portfolioData: {
      portfolioData: [
        { asin: "B08JKK4217", sku: ["130520"]},
        { asin: "B08JKP82PB", sku: ["130521"]}
      ]
    }
  }
]

const B = {
  ProductMetadataList: [
    { asin: "B08JKK4217", sku: "130520"},
    { asin: "B08JKP82PB", sku: "130521"},
    { asin: "B08JKP82PB", sku: "13052221"}
  ]
}

let indexes = [] // matching indexes of array B

for(item of A){
  let portfolioData = item['portfolioData']['portfolioData']
  
  portfolioData.forEach((el_A) => {
    B.ProductMetadataList.forEach((el_B, i) => {
    
      // conditions
      let C1 = el_A.asin === el_B.asin
      let C2 = el_A['sku'].join() === el_B['sku']
      let C3 = !indexes.includes(i)
      
      // save index if there is a match and the index has not been saved before
      if(C1 && C2 && C3) indexes.push(i)
    })
  })
}

let result = B.ProductMetadataList.filter((el,index) => !indexes.includes(index))

console.log(result)

A simple approach, easy to read, would be to register the indexes of the array B of the matching data and then filtering by these indexes.

Note: I reduced the arrays to make the code easier to read. It will work with your data.

const A = [
  { 
    campaignId: "3964126695264",
    portfolioData: { 
      portfolioData: [
        { asin: "B08JKK4217", sku: ["130520"]},
        { asin: "B08JKP82PB", sku: ["130521"]}
      ]
    }
  },
  { 
  campaignId: "137244687845173",
    portfolioData: {
      portfolioData: [
        { asin: "B08JKK4217", sku: ["130520"]},
        { asin: "B08JKP82PB", sku: ["130521"]}
      ]
    }
  }
]

const B = {
  ProductMetadataList: [
    { asin: "B08JKK4217", sku: "130520"},
    { asin: "B08JKP82PB", sku: "130521"},
    { asin: "B08JKP82PB", sku: "13052221"}
  ]
}

let indexes = [] // matching indexes of array B

for(item of A){
  let portfolioData = item['portfolioData']['portfolioData']
  
  portfolioData.forEach((el_A) => {
    B.ProductMetadataList.forEach((el_B, i) => {
    
      // conditions
      let C1 = el_A.asin === el_B.asin
      let C2 = el_A['sku'].join() === el_B['sku']
      let C3 = !indexes.includes(i)
      
      // save index if there is a match and the index has not been saved before
      if(C1 && C2 && C3) indexes.push(i)
    })
  })
}

let result = B.ProductMetadataList.filter((el,index) => !indexes.includes(index))

console.log(result)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文