Created
November 19, 2024 13:01
-
-
Save sagarpanchal/092395095756465db0ec8ca9d57b4121 to your computer and use it in GitHub Desktop.
Freeze Set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const frozenSet = (iterable) => { | |
const s = new Set(iterable); | |
s.add = s.delete = s.clear = undefined; | |
return s; | |
}; | |
const test = frozenSet([1, 2, 3, 1, 2]) | |
test.add(4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment