剩余数组(从'水果数组'筛选掉'吃了的数组')

fruits = ['香蕉','苹果','梨子','水蜜桃','橘子','橙子'];
eatfruit = ['香蕉','水蜜桃','橘子'];
other = [];

this.other = this.fruits.filter(item => {
   return this.eatfruit.every(item2 => {
          return item != item2;
      });
   }).map((item) => {
       return item;
});

转载于:https://www.cnblogs.com/yuyedaocao/p/11009229.html

猜你喜欢

转载自blog.csdn.net/weixin_34365635/article/details/93338277