The hash set data structure
A hash set is a collection of unique values (no duplicates allowed). It combines the characteristics of a mathematical set with the efficiency of hash tables. Like hash tables, hash sets use a hash function to calculate a hash code for each element (value) we want to store. This hash code determines the index (bucket) where the value should be placed in an underlying array.
We can reuse the code we created in this chapter to create the hash set data structure as well, but with one important detail: we would need to check for duplicate values before the insertion operation.
The benefits of using hash sets are that it is guaranteed that all values in the set are unique. In JavaScript, the native Set class is considered a hash set data structure as well. For example, we could use a hash set to store all the English words (without their definitions).