Data Structures for JavaScripts
JavaScript data structures are the built-in containers for grouped data: arrays for ordered lists, plain objects for key-value records, and Map and Set for keyed collections and unique values. This unit sits in the Language Core stage and covers how to create, loop over and transform them with methods like map and filter.
Stage: Language Core · Part of the JavaScript roadmap · Last reviewed 19 November 2026
What to learn in Data Structures
- Transform arrays with map, filter and reduce instead of manual loops
- Copy and merge objects using the spread operator and destructure their fields
- Choose a Map over a plain object when keys are not strings
- Remove duplicates from an array using a Set
- Explain the difference between a shallow copy and a deep copy
Data Structures interview questions
What is the difference between map and forEach on an array?
map returns a new array built from the return value of each callback call, so it is used to transform data. forEach returns undefined and is used for side effects such as logging. You cannot chain after forEach, but you can after map.
When would you use a Map instead of an object?
Use a Map when keys are not strings, when insertion order and size matter, or when you add and remove keys often. Maps accept any value as a key and have a size property. Plain objects suit fixed, known shapes such as records.
Where Data Structures fits in the JavaScript roadmap
Data Structures belongs to the Language Core stage (beginner level), which takes about 28 hours. Syntax and data.
Other units in this stage
Back to the full JavaScript roadmap