Replace Object with Map in your JavaScript code

Photo by Timo Wielink on Unsplash

1. Map.size vs Object.keys(object).length

count map’s length by size property
Count object’s length
experiment comparing elapsed time counting length
Result Table

Map.has(key) vs Object.keys(object).includes(key)

map’s has property

Map.delete(key) vs delete object[key]

map’s delete method

Map is iterable

for…of iterate Map

Relation with Array

Map to Array
Array to Map

Merge multiple Maps

merge maps
Browser support for Map


A Certified Public Accountant / Hobbyist-but-serious programmer specializing Python, ReactJs, Blockchain / anarchist / Libertarian / Would-be digital nomad

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store