The Planner

God has an excellent plan for us. We should complain less and believe more. We have no full understanding of how God is architecting our lives now, yet further along, God will make all things…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Understanding maps in JavaScript

A brief intro to the JavaScript map object and the methods and properties we can use to work with it.

A blob of code in a text editor showing the creation of a JavaScript map and some methods.

This article looks to explain what a map is and to go through some of the various methods and properties available when working with maps.

What is a map?

A map is a collection of key:value pairs that can use any type of data as a key and maintain the order of its entries.

This creates an empty map:

We can also initialise a map with values by passing in an array of arrays.

Adding properties to a map

Looking at the map in the console we see the new values and properties:

This looks similar to an object using string-based keys, but with a map we can use any type of data as a key.

Maps do not allow for the duplicate use of key values. In the following example the string one and the number one get treated as unique keys, but…

Add a comment

Related posts:

Derek Carr Is a Boring Pick. Is He a Good One?

Does it seem like Derek Carr should be the highest paid player in the NFL? Carr recently signed a 5-year $125-million extension after a season that saw him emerge as a franchise quarterback before…

The Laundry Room

Living in a multi-family unit never has its perks. In my building we have a shared laundry room… There’s one washer and 2 dryers for 8 apartments to share. I’m sure the community’s brochure lists…

What You Need to Hear

In the whirlwind of life, so often we get swept up in the business of work. Particularly if you are a manager or view yourself as a leader. In these roles we take on responsibilities beyond our tasks…