拷贝数组中合集

  • 计算合集
const dayCount = [0,1,2,3]; const weekCount = [0,1,2] // 计算天数集合、星期集合的交集 const dayArr = new Set(dayCount); const weekArr = new Set(weekCount); const sameArr = Array.from( new Set([...dayArr].filter(x => weekArr.has(x))) ); console.log(sameArr) // [0,1,2]

    推荐阅读