Maps in JavaScript

Atta on June 19, 2019

Maps are a new data structure in JavaScript that allows you to create collections of key-value pairs. They were introduced with ES6 (also called ES... [Read Full]
markdown guide

This is a great overview! I was expecting it to be the other map as that seems to be what people focus on and use more. But I am pleasantly surprised that you are highlighting less used but very useful functionality.

Why people dont use these more is a mystery to me. I often see people using Objects or even JSON without ever stopping to think about Map


May be because Maps are relatively new (introduced in ES6) whereas Objects are around since JavaScript version 1 and supported by all browsers.


You wrote

Calling add() more than once with the same key won't add multiple key-value pairs.

I believe you may have meant set()


Yeah, it should be set() method for maps :) I updated the post.


Thank you so much for this post. I've been stucked on map for awhile now and i have been using references online but this is the only one i've found useful so far.


Thank you! I'm glad it helped ✌️


Wow, I didn't know that, thanks !
I don't see use cases for now but it seems pretty cool .


Actually Map.prototype.forEach does not behave like his array cousin. It returns a iterator.

code of conduct - report abuse