Re:New JavaScript Set Methods
by threatofrain on Monday June 24, 2024 @12:14PM
(#40777856)
If you do use objects I might suggest Object.create(null).
+1 Was going to be my response as well...
Yup. I always use Set and Map over objects. They just contain way fewer surprises and the APIs actually work as you would expect. I only use Objects for "struct" like objects with a known set of keys that are used by name. It is also nice because it conveys more intent to the reader.
Some properties cannot be deleted, and some cannot be modified:
Sets also allow you to have sets of other types rather than just strings and symbols.