+ 2
What does new Map do and why is the output 1?
let arr = [1, 1, 5, 5, 6, 7, 6]; let map = new Map([arr, arr]); console.log(map.size); And why is the output also 1 when having new Map ([arr]); instead of ([arr, arr])? https://code.sololearn.com/Wf8YLS1bp06u/?ref=app
1 Answer
+ 2
ES6 Map is an associative array so the data in map stores like that
'key' => 'value'
Example:
var map = new Map([['key1', 'value1'], ['key2', 'value2']]);