Question: The Set implementation provided as a standard built-in JavaScript object does not support the intersection operation. Monkeypatch Set so as to add it in

The Set implementation provided as a standard built-in JavaScript object does not support the intersection operation. Monkeypatch Set so as to add it in as a non-destructive operation. > x = new Set ([5, 6, 2, 3, 5]) Set (4) 5, 6, 2, 3} > x.intersection (new Set ([1, 2, 3, 4])) Set (2) {2, 3} > x //unchanged; operation non-destructive Set (4) 5, 6, 2, 3} > x.intersection (new Set ([])) Set (0) { } > x Set (4) 5, 6, 2, 3} > new Set ([9, 8, 7]). intersection (x) Set (0) { } Your implementation may only use Set operations. Specifically, you may not use Array operations.
Step by Step Solution
There are 3 Steps involved in it
o add the intersection operation to the Set class in JavaScript you can extend the Setprototype wi... View full answer
Get step-by-step solutions from verified subject matter experts
