I have been searching on how should new Map(); be used and how to assign values from both to the object or return the object.
I have found usage of new Map(); on the MDN webdocs which is:
let myMap = new Map();
myMap.set('key', 'value');
console.log(myMap.get('key'))
I have found in one of the posts it can be used as follows as well:
let myMap = new Map();
myMap['key'] = 'value';
console.log(myMap['key']);
I have used myMap['key'] way of of new Map() before but as i tried to return the map it seemed different.
This is example which shows difference between the two:
let myMap0 = new Map();
let myMap1 = new Map();
myMap0.set('key','value');
myMap1['key'] = 'value';
console.log(myMap0);
console.log(myMap1);
Given example doesn't look alike in Google Chrome which is:

Overall this is really confusing for me as i am unsure which way is the way it is supposed to be used.
I got used to myMap['key'] = 'value'; as this is how it works in Golang.
Additionaly i have found more solutions to the myMap.set('key', 'value');way of usage.
setmethod is the correct way. Otherwise you’ll always have asizeof0and no entries, as you see in the console. You’re just adding properties, but not entries.Mapobject is very likely not what you want. Just use a normal object.