How to get the Length of a Map in JavaScript-Code Examples

Victor Talmacinschi

How to get the Length of a Map in JavaScript

JavaScript by Victor Talmacinschi June 21, 2022

const map = new Map();

map.set('🍎', 'Apple');
map.set('🍐', 'Pear');
map.set('🍊', 'Orange');

// To get the length of a Map in JavaScript, we can use the size property:
console.log(map.size); // 3

0

19.801

How to get the Length of a Map in JavaScript

JavaScript by Victor Talmacinschi June 21, 2022

var map = new Map();

//set some key-value pairs
map.set('🍕', 'pizza');
map.set('🍔', 'burger');
map.set('🍟', 'fries');

//get the size of the map
console.log(map.size); //3

0

19.801

Related JavaScript Queries

Latest JavaScript Queries

Explore code examples by categories