JS TutorialLesson 23Free preview
JS Maps
This lesson is part of JavaScript · All levels
Summary
A map is a collection of key-value pairs like a regular object, but its keys can be of any type including objects, functions, and arrays. The map also stores the order of insertion and has special methods such as set, get, has, delete, as well as size properties. Maps are superior to objects when data requires a non-string key or data sequence to be maintained.
Key points
- It is made with new Map(), then filled with set(key, value)
- Take the value, check it, delete it
- The key can be of any type and the order of insertion is maintained.
- Size gives the number of entries; ordinary objects use Object.keys().length
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.