js判断一个数组是否包含另一个数组

      const a = [1, 2, 3, 4, 5, 6, 7, 8]
      const b = [5, 5, 1, 2]
      const c = [3, 9]

      // 判断arr1是否包含arr2
      const isInclude = (arr1, arr2) => arr2.every((val) => arr1.includes(val))
      console.log(isInclude(a, b)) // true
      console.log(isInclude(a, c)) // false

 

posted @ 2022-04-27 10:47  吴小明-  阅读(2059)  评论(0编辑  收藏  举报