Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Output an Object vs a Map #12

Closed
bmeck opened this issue Jul 20, 2021 · 2 comments
Closed

Output an Object vs a Map #12

bmeck opened this issue Jul 20, 2021 · 2 comments

Comments

@bmeck
Copy link
Member

bmeck commented Jul 20, 2021

With a Map, grouping don't have to be on key compatible types and avoids coercions:

o = {};
o[1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000] = 1;
Object.keys(o); // ["1e+90"]

Using an object knowledge of key coercion might be a bit odd.

Problems with Map are usability on reading data out of the Map not being simple property access though but you can always Object.fromEntries(map).

@ljharb
Copy link
Member

ljharb commented Jul 20, 2021

This came up briefly in plenary. Maps are simply not ergonomic enough to be the primary return type for this API - like it or not, object are the way people pass around data, and property key conversion is a non-issue for most use cases (and is pretty commonly understood, imo)

#3 covers adding a secondary way to get a Map out, for those that want it.

@bmeck
Copy link
Member Author

bmeck commented Jul 20, 2021

seems fine, I wouldn't call it understood though

@bmeck bmeck closed this as completed Jul 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants