DSA · Arrays & hashing
Store associations in a Map
Use Map<K, V> when each key points to a value: for example, value → index, word → count, or userId → user. It supports keys of any type and makes the association explicit.
const indexByName = new Map<string, number>();
indexByName.set("Ada", 0);
const index = indexByName.get("Ada"); // 0 | undefined