DEV Community

Discussion on: Learn the Incredibly Helpful but Often Overlooked JavaScript Built-In Set Object

Collapse
 
leob profile image
leob • Edited

Nice overview, this is the kind of "dev.to" article that I like :-)

For the toggle/binary state thing I tend to use plain JS objects, e.g.:

const isOpen = {};
...
isOpen[menuItem] = true;
...
if (isOpen[menuItem]) ...
...
delete isOpen[menuItem];

But I agree that Set is probably a better choice!