DEV Community

Discussion on: Simplifying code with Maps in JavaScript

Collapse
 
ledu6 profile image
Benoit LEGER-DERVILLE

Hi Alex,

Thanks for this short pro Map, but I don't understand why you can access the Map value element using cardType [Object] only (like this in your code)

const [title, Icon] = typeMap.get(cardType)

and not using his value prop ?

const [title, Icon] = typeMap.get(cardType.value)

Collapse
 
clarity89 profile image
Alex K.

Hi Benoit,

Thank you for the comment. It actually should be const [title, Icon] = typeMap.get(cardType.value), I've forgot to update it after introducing the dropdown. I'll fix it in the article.

Thank you for pointing it out!