I’m working in JavaScript. I’d like to store a list of unique, unordered string values, with the following properties:
- a fast way to ask ‘is A in the list’?
- a fast way to do ‘delete A from the list if it exists in the list’
- a fast way to do ‘add A to the list if it is not already present’.
What I really want is a set. Any suggestions for the best way to mimic a set in JavaScript?
This question recommends using an Object, with the keys storing properties, and the values all set to true: is that a sensible way?