|
|
|
|
|
by kevincox
1145 days ago
|
|
I would argue that all "mapping" structures should use Map these days. Objects should be used only for record/struct data with a fixed set of programmer-named keys. I think MDN has a good comparison: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... The only real downside of maps is that they don't support JSON serialization. However you can fix this pretty easily by using a map with an overridden `toJSON` for serializable keys. class StringMap extends Map {
toJSON() {
return Object.fromEntries(this);
}
}
|
|