The options
Array
An ordered list indexed by position.
Sequences you read in order, sort, slice, or address by index; the default for lists of items.
Set
A collection of unique values with fast membership tests.
Tracking distinct items, deduplicating, and answering is X present in constant time.
Map
Key-to-value pairs where the key can be any type.
Lookups by an arbitrary key (including objects), counters, and caches that need ordered or non-string keys.
Object / Record
String-keyed pairs, the native record type.
Fixed-shape records and string-keyed lookups where you know the keys ahead of time.
Tree
Nodes with one parent and children, a hierarchy.
Nested, hierarchical data: file systems, DOM, org charts, and recursive structure traversal.
Graph
Nodes connected by arbitrary edges, a network.
Many-to-many relationships: social networks, maps, dependencies, and recommendation graphs.
Which one fits you?
Answer a few questions to get a recommendation.
Question 1 of 4