听听那晚风
2021-01-20 17:58
采纳率: 58.3%
浏览 246
已采纳

将对象数组a中不包含数组b里的元素的项去除

var a = [
        { name: "aa", children: [{ name: "aa1" }, { name: "aa2" }] },
        { name: "bb", children: [{ name: "bb1" }, { name: "bb2" }] },
        { name: "cc", children: [{ name: "cc1" }, { name: "cc2" }] },
        { name: "dd", children: [{ name: "dd1" }, { name: "dd2" }] },
        { name: "ee", children: [{ name: "ee1" }, { name: "ee2" }] },
      ];
var b = ["aa1","aa2","cc1", "bb2","dd1" ];
//目标对象
var mune = [
        { name: "aa", children: [{ name: "aa1" },{ name: "aa2" }] },
        { name: "bb", children: [{ name: "bb2" }] },
        { name: "cc", children: [{ name: "cc1" }] },
        { name: "dd", children: [{ name: "dd1" }] },
      ];

2条回答 默认 最新

相关推荐 更多相似问题