A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/javascript-map-size-property/ below:

JavaScript Map size Property - GeeksforGeeks

JavaScript Map size Property

Last Updated : 23 Jul, 2025

Map is a collection of elements where each element is stored as a Key, value pair. The Map.size property returns the number of key, and value pairs stored in a map.

Syntax
mapName.size
Return Value

An integer representing the number of key, value pairs stored in a map.

The below examples illustrate the Map.size property.

Example 1:

JavaScript
let GFGmap = new Map();

// Adding key, value pairs to the map
GFGmap.set('1', 'Apple');
GFGmap.set('2', 'Banana');
GFGmap.set('3', 'Mango');

// Printing number of key, value
// pairs stored in the map
console.log(GFGmap.size);

Output:

3

Example 2:

JavaScript
let GFGmap = new Map();

// Adding key, value pairs to the map
GFGmap.set('a', 'Apple');
GFGmap.set('b', 'Ball');
GFGmap.set('c', 'Cat');
GFGmap.set('d', 'Dog');

// Printing number of key, value
// pairs stored in the map
console.log(GFGmap.size);

Output:

4
Supported Browsers

We have a complete list of Javascript Map methods, to check those please go through this JavaScript Map Complete Reference article.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4