[html] const nums1 = [1, 2, 2, 1], nums2 = [2] 交集是什么?
生活随笔
收集整理的這篇文章主要介紹了
[html] const nums1 = [1, 2, 2, 1], nums2 = [2] 交集是什么?
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
[html] const nums1 = [1, 2, 2, 1], nums2 = [2] 交集是什么?
let a = [1, 2, 2, 1]; let b = [2]; let aSet = new Set(a); let bSet = new Set(b);let intersection = Array.from(new Set(a.filter(v => bSet.has(v)))) console.log(intersection); // [2]個人簡介
我是歌謠,歡迎和大家一起交流前后端知識。放棄很容易,
但堅持一定很酷。歡迎大家一起討論
主目錄
與歌謠一起通關前端面試題
總結
以上是生活随笔為你收集整理的[html] const nums1 = [1, 2, 2, 1], nums2 = [2] 交集是什么?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: tomcat编码配置gbk_Tomcat
- 下一篇: [html] 使用canvas制作一个