File tree 1 file changed +6
-0
lines changed
1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ const union = (set1, set2) => {
35
35
} ;
36
36
console . log ( union ( setA , setB ) ) ;
37
37
38
+ console . log ( new Set ( [ ...setA , ...setB ] ) ) ;
39
+
38
40
// --------- Intersection ----------
39
41
const intersection = ( set1 , set2 ) => {
40
42
const intersectionSet = new Set ( ) ;
@@ -47,6 +49,8 @@ const intersection = (set1, set2) => {
47
49
} ;
48
50
console . log ( intersection ( setA , setB ) ) ;
49
51
52
+ console . log ( new Set ( [ ...setA ] . filter ( x => setB . has ( x ) ) ) ) ;
53
+
50
54
// alternative - works on FF only
51
55
// console.log(new Set([x for (x of setA) if (setB.has(x))]));
52
56
@@ -62,5 +66,7 @@ const difference = (set1, set2) => {
62
66
} ;
63
67
console . log ( difference ( setA , setB ) ) ;
64
68
69
+ console . log ( new Set ( [ ...setA ] . filter ( x => ! setB . has ( x ) ) ) ) ;
70
+
65
71
// alternative - works on FF only
66
72
// console.log(new Set([x for (x of setA) if (!setB.has(x))]));
You can’t perform that action at this time.
0 commit comments