Closed mathiasbynens closed 3 years ago
I think until its common practice to serialize/deserialize JSON using Map
(which is already possible today with the JSON.parse/stringify
methods, but as far as I can tell is not popular) we're going to continue to see lots of code make use of objects-as-dictionaries. Searching through public usage of libraries that provide has(o, p)
you'll find lots of examples of using has()
with request/json-body data.
Until Map
and Set
literals appear, Object
and Array
will be used more frequently due to the ease of declaration even if Map
and Set
are more suitable data structures.
All the arguments for adding Object.fromEntries
apply here; just like the existence of Set didn't obviate arrays-as-sets, the existence of Map doesn't obviate objects-as-dictionaries.
For the record, I agree with everything you're saying, and have written about it before: https://v8.dev/features/object-fromentries#objects-vs.-maps I'm merely suggesting to document this rationale in the FAQ to get ahead of the debate :) (Same with the other issue I filed.)
Yup, I was just trying to work out the reasoning in issues before committing them to the explainer doc
Which use cases of objects-as-dictionaries are not better handled by using
Map
s?