Hash Map

A hash map (also called a dictionary or hash table) stores data as key-value pairs and lets you look up a value by its key almost instantly.

General Programming

It uses a hash function to convert each key into a position where its value is stored, giving very fast lookups, inserts, and deletes on average. In Python it is the dict; in JavaScript it is the Map or plain object.

Examples

Python

ages = {"Ada": 36, "Alan": 41}
print(ages["Alan"])

Output:

41

JavaScript

const ages = { Ada: 36, Alan: 41 };
console.log(ages.Alan);

Output:

41

See also

Back to the Dictionary