Answers for "javascript size of map"

C++
1

js map size

const map1 = new Map();

map1.set('a', 'alpha');
map1.set('b', 'beta');
map1.set('g', 'gamma');

console.log(map1.size);
// expected output: 3
Posted by: Guest on March-15-2021
7

map()

The map() method creates a new array populated with the results of calling 
a provided function on every element in the calling array.

const array1 = [1, 4, 9, 16];

// pass a function to map
const map1 = array1.map(x => x * 2);

console.log(map1);
// expected output: Array [2, 8, 18, 32]
Posted by: Guest on October-09-2020

Browse Popular Code Answers by Language