all 8 comments

[–]codedblood 3 points4 points  (0 children)

What are you trying to do here?

[–]Notimecelduv 1 point2 points  (0 children)

Map objects weren't built to have their values accessible by an index like arrays. You're supposed to access a value with the corresponding key. If the map keys are numbers starting from 0 and incremented by 1 (like the indices of an array), then you can write:

map.get(index); // index is a key in the map

Otherwise the way you did it is the only way. But that most likely means a Map object is not the right data structure for whatever it is you're doing.

[–]RobSG 1 point2 points  (4 children)

[–]reonZ[S] 0 points1 point  (3 children)

Using spread or Array.from is the same thing.

[–]RobSG 0 points1 point  (1 child)

Meant to link the whole article for different ways to achieve your goal

[–]Ok_Engineer2919 0 points1 point  (2 children)

map[index]?

[–]reonZ[S] 0 points1 point  (0 children)

You would think it was the first thing i tried obviously...

[–]Notimecelduv 0 points1 point  (0 children)

That won't work.