判断一个数组是否是另一个数组的子集、数组去重

 //判断一个数组是否是另一个数组的子集
  let brr = [1, 2]
  let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
  // console.log(res)
  function subsetTo(ziArr, fuArr) {
    return ziArr.every(v => fuArr.includes(v))
  }
  console.log(subsetTo(brr, arr)) // true

  //数组去重
  let quChong = [7, 8, 7, 7, 9];
  function unique(quChong) {
    return Array.from(new Set(quChong))
  }
  console.log('quChong', unique(quChong)); // [7, 8, 9]

//数组大于10的数
  let array1 = [5, 12, 8, 130, 44]
  const found = array1.filter(i => i > 10)   
  console.log('found', found)  //[12, 130, 44]

你可能感兴趣的:(js,javascript,开发语言,ecmascript)