---
title: "Discussion on \"JS Capsules: Maps\" | Hashnode"
description: "Discussion on \"JS Capsules: Maps\". Introduction\nA Map is a collection of elements, where each element is stored as a key: value pair.\nBy this definition, it can seem similar to an Object, but while a Map can accept any data type (both primitive values and objects) as its key, an Objec..."
url: "https://hashnode.com/posts/js-capsules-maps/62c20f4dccecfb25bbc769ff"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [JS Capsules: Maps](https://dpkreativ.hashnode.dev/js-capsules-maps?utm_source=hashnode&utm_medium=feed)

Introduction A Map is a collection of elements, where each element is stored as a key: value pair. By this definition, it can seem similar to an Object, but while a Map can accept any data type (both primitive values and objects) as its key, an Objec...

Jul 3, 2022 · 4 min read · dpkreativ.hashnode.dev  
Read the article

-   [#2articles1week](https://hashnode.com/tag/2articles1week)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#data-structures](https://hashnode.com/tag/data-structures)
-   [#series](https://hashnode.com/tag/series)

## Written by

[Divine Orji](https://hashnode.com/@dpkreativ)

@dpkreativ

  
[View profile](https://hashnode.com/@dpkreativ)

Software Engineer

I am a software engineer passionate about building fast, scalable apps with beautiful user interfaces.

## Responses 3

Markdown supported · ⌘↵ to post

[Ridwan Olanrewaju](https://hashnode.com/@ibnlanre)

[Jul 6, 2022](https://hashnode.com/posts/js-capsules-maps/62c20f4dccecfb25bbc769ff/comment/62c53ad2d2e08c68f6e7a010)

Excellent article. I should mention though, that an Object can have a `number` as a property key.

**For Example:**

```
const x = { 7: "tight" } // undefined
x[7] // 'tight'
```

[Fecharalua](https://hashnode.com/@Fecharalua)

[Jul 6, 2022](https://hashnode.com/posts/js-capsules-maps/62c20f4dccecfb25bbc769ff/comment/62c53ad2d2e08c68f6e7a010#reply-62c576a57b0f3b700c5450b4)

If the key is of type Number, it will be converted to a String. So the value of x\['7'\] is also 'tight'.

[Divine Orji](https://hashnode.com/@dpkreativ)

[Jul 6, 2022](https://hashnode.com/posts/js-capsules-maps/62c20f4dccecfb25bbc769ff/comment/62c53ad2d2e08c68f6e7a010#reply-62c5a7b7c8efe473b8fe41a3)

[Fecharalua](https://hashnode.com/@Fecharalua)'s correct. JavaScript will convert an Object's key to a string.

[Héctor Ramírez](https://hashnode.com/@hexram)

[Jul 6, 2022](https://hashnode.com/posts/js-capsules-maps/62c20f4dccecfb25bbc769ff/comment/62c4e7ff6d73625bbffdd6e4)

As a constant learner I never miss an opportunity to increase my knowledge. Your article helped me expand my experience and be better prepared for future problem solving.

[Divine Orji](https://hashnode.com/@dpkreativ)

[Jul 6, 2022](https://hashnode.com/posts/js-capsules-maps/62c20f4dccecfb25bbc769ff/comment/62c4e7ff6d73625bbffdd6e4#reply-62c5a735c8efe473b8fe418e)

Glad to have helped! [Héctor Ramírez](https://hashnode.com/@hexram)

[Idris Abdul-Lateef](https://hashnode.com/@eedris)

[Jul 4, 2022](https://hashnode.com/posts/js-capsules-maps/62c20f4dccecfb25bbc769ff/comment/62c262fec0401b3dcbcfbcaf)

Brilliant article! 👏

[Divine Orji](https://hashnode.com/@dpkreativ)

[Jul 4, 2022](https://hashnode.com/posts/js-capsules-maps/62c20f4dccecfb25bbc769ff/comment/62c262fec0401b3dcbcfbcaf#reply-62c296acc0401b3dcbcfc6b2)

Thanks Abdul!
