30 Days Of JavaScript

Day 2: Collection Types

Lesson 4: Maps

In programming a map is basically a fancy name for an object, you'll hear the term in a number of places. In JavaScript it is basically an object with some rules about how they work.

Maps differ from objects in a few ways:

  • Can only set or remove values with .set() and .delete() methods
  • Have to be created with a constructor new Map()
  • A key can be any data type, not just a string
  • Maps know the order their data was added in
  • They know their size
  • Are iterable (we'll come on to this later)

And that's really it. Maps are technically better than objects but in reality objects are so quick and easy to use in JavaScript, most people just stick to using them.


Go Pro?

If you upgraded to pro, sign in here

  • About
  • Blog
  • Privacy
Looking to email me? You can get me on my first name at allthecode.co