DEV Community

Lautaro Suarez
Lautaro Suarez

Posted on

1

What`s new Map()?

Lets talk about whats "new Map()".

Uses
We could use it to define a new object where then calling the key we would be able to get the value on the specific value.

Usage
The usage of it is as follows.

First we will see how we declare the variable "objMap" as the "new Map()" object will have.
Then we will set the value it will have calling "objMap" and the internal function "Map()" have. The first value we pass to it will be the key of the object. For example: If we just pass "objMap.set("1", "Hola")", the value will be "Hola" and the key will be "1".
And finally there are examples of how to get the values doing different console.logs, we will see that the first one will return "Hola" and the second console.log will return undefined cause the is not a "2" key.

Image description

This post is to explain the concept used in the last post.

Hope someone found it useFul.

Lautaro

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay