Favorites

JavaScript Map.prototype.size Property

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Map.prototype.size
JavaScript Map Instance propertyThis property is supported by all modern browsers.
Updated 28th November 2026

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.size

Value

The number of entries in the Map.

Example

const m = new Map([['a', 1]]);
m.set('b', 2);
console.log(m.size);

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

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee