3 ms·
Why did they not make the map assigning syntax as convenient as with objects, instead going for the clunky get/set?
by eviks 4y ago
Why did they not make the map assigning syntax as convenient as with objects, instead going for the clunky get/set?
- panzerboiler 4y agoBecause a Map is an Object. It has properties and methods. The only way to provide a safe and clean namespace for your keys is to provide an explicit API. It also supports keys that can be not only strings or symbols.
- beebeepka 4y agoSeveral things such as standard way for adding, removing and checking for keys, built-in size property, extensibility. You think "key in object" is better than "maaaaap.has(key)"? I don't because it's unpredictable and prone to exceptions. Give them a try. It's not a complete replacement for regular old objects