JavaScript · Senior · Question 38 of 75
What does new Set([1, 2, 3]).intersection(new Set([2, 3, 4])) return?
- ✓Correct answer:
Set {2, 3} - 2
Set {1, 2, 3, 4} - 3
TypeError: no such method
Explanation
Since 2024, Set has set-theory methods: union, intersection, difference, symmetricDifference, isSubsetOf and more. Previously this was written by hand with filter. Check target browser support before using it in production.