To find the values of a map in JavaScript, we can iterate over the map object using its keys()
method and access the values using its get()
method. Here is an example:
index.tsx284 chars14 lines
In this example, we create a new map myMap
and add three key-value pairs to it. Then, we iterate over the keys of the map using a for-of
loop and access the values of the map using the get()
method. Finally, we log the values to the console.
Output:
index.tsx21 chars4 lines
gistlibby LogSnag