JavaScript Map.prototype.size Property
JavaScript Map Instance propertyThis property is supported by all modern browsers.
The size property gives the number of entries in a Map.
Description
The size property returns the number of entries. It is read-only and updates automatically, unlike plain objects where you'd need Object.keys(obj).length.
Unlike an array's length, size can't be set; to remove entries, use delete() or clear(). Checking map.size === 0 is the simplest way to see whether a map is empty.
WeakMap has no size, because its entries can disappear at any time when their keys are garbage-collected.
Syntax
map.sizeValue
The number of entries in the Map.
Example
Browser Support
The following information will show you the current browser support for the Map.prototype.size property. Hover over a browser icon to see the version that first introduced support for this property.
This property is supported by all modern browsers.
Desktop





Tablets & Mobile






-
Supported Unknown Not supported
Sponsors
Password Manager
PasswordPal stores your passwords and private notes behind encryption that happens in your browser.
Copy Paste List
Copy and paste or download lists in your preferred format, including plain text, PDF, or HTML.
Unicode Characters & Emojis
Search all Unicode characters and emojis plus other tools.
Check Shortened URLs
Expand shortened URLs to view the destination link.
Advertise Here
Advertise your company and products here!