Logo

Programming-Idioms

History of Idiom 170 > diff from v13 to v14

Edit summary for version 14 by RohanL:
New JS implementation by user [RohanL]

Version 13

2019-09-26, 14:28:25

Version 14

2019-09-26, 14:30:49

Idiom #170 Get map size

Set n to the number of elements stored in mymap.

This is not always equal to the map capacity.

Idiom #170 Get map size

Set n to the number of elements stored in mymap.

This is not always equal to the map capacity.

Extra Keywords
length count
Extra Keywords
length count
Code
const map = new Map()
map.set("a", 1)
const length = map.size
Doc URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size