Map (collection)
A built-in JavaScript collection of key-value pairs where keys can be any value, including objects, kept in insertion order.
In more detail
Keys are compared by identity, so two different objects with the same contents are two keys. Map can be iterated and has a size, but it keeps its keys alive, so using DOM elements as keys can leak them.
Related terms
- WeakMap — A key-value collection whose keys must be objects and are held weakly, so an entry disappears when its key object is garbage collected.
- Set object — A built-in JavaScript collection of unique values.
- repository pattern — Putting all the code that reads and writes one kind of data behind a single object, so the rest of the app never talks to the database directly.
- in-memory cache — A store in the program's memory that keeps recently fetched values so they can be reused without asking the original source again.
- Record — A built-in TypeScript type, Record<K, V>, for an object whose keys are of type K and values of type V.
Taught in
- Deep Flexbox: Flex Grow, Shrink, Basis And Alignment Physics — Frontend Architecture & Web Platform
- Memory Management: Garbage Collection, Memory Leaks And WeakMap — Frontend Architecture & Web Platform
- Web Workers: Off-Thread Computation And Structured Clone — Frontend Architecture & Web Platform
- Generic Interfaces, Classes And Type Aliases — Production TypeScript