Arun Jacob
Feb 12, 2021

--

Thank you Reed, it was easy to understand the advantages of Map over normal Objects.

One peculiar thing observed was that with Objects, it was easy to define the keys on the fly(yes, they were converted to strings implicitly) like below:-

var person = {name: "John", age: 29};

with Maps:-

var person = new Map();

person.set(name,"John");//wouldn't work as it seems Map was expecting they key to be an already defined object(in the case of primitives as keys, yes they were already defined and no issues.

person.set(1,"John")//this works

also if explicitly mention key as a string, then no issues as string was already defined.

person.set("name","John");//works

Not an issue, particularly the point were objects are used as keys was very helpful.

Thank you

--

--

Arun Jacob
Arun Jacob

Written by Arun Jacob

Tech. Enthusiast, develops user journeys for SAP Enterprise Applications.

No responses yet