javascript size of map code example
Example 1: js map size
const map1 = new Map();
map1.set('a', 'alpha');
map1.set('b', 'beta');
map1.set('g', 'gamma');
console.log(map1.size);
Example 2: size of map with no elements
#include <iostream>
#include <utility>
#include <map>
using namespace std;
int main(void)
{
map<int, int> m;
cout << m.size();
}
Example 3: nodejs map
let wrongMap = new Map()
wrongMap['bla'] = 'blaa'
wrongMap['bla2'] = 'blaaa2'
console.log(wrongMap)
Example 4: 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];
const map1 = array1.map(x => x * 2);
console.log(map1);