August 2024
Intermediate to advanced
516 pages
11h 47m
English
Because hash tables keep data in pairs, they’re useful in many scenarios for organizing data.
Some data exists naturally in paired form. The fast-food menu and thesaurus scenarios from this chapter are classic examples. The menu contains each food item paired with its price. The thesaurus contains each word paired with its synonym. In fact, this is why JavaScript refers to hash tables as dictionaries. A dictionary is a common form of paired data; it’s a list of words with their respective definitions.
Other examples of naturally paired data can include tallies, such as political candidates and the number of votes each received:
| | {"Candidate A": 1402021, "Candidate B": 2321443, "Candidate C": 432} |
An inventory ...
Read now
Unlock full access