Bug 1739648 Comment 16 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

The underlying reason this was included as part of the proposal according to the champion is that will be useful with [records and tuples](https://github.com/tc39/proposal-record-tuple). In other words, you can create composite keys without defining an object outside of the function scope. 

There are use cases for objects as keys in a map, and it is expected that you will hold a reference to it if you want to access it. You can see this in action here: https://searchfox.org/mozilla-central/rev/94d7c959115c03ea1e9406d6105b36cabe63775d/browser/components/extensions/parent/ext-devtools.js#197,217 -- Objects change over time, so transforming an object into a string representation will result in the key and the actual object getting out of sync -- leading to a loss of access to the values without some synchronization point, or without mapping it to some identifier. When you are using an object as a key in a map, it is because you are mapping related information to that specific object. The same applies to groupByToMap.
The underlying reason this was included as part of the proposal according to the champion is that will be useful with [records and tuples](https://github.com/tc39/proposal-record-tuple). In other words, you can create composite keys without defining an object outside of the function scope. 

There are use cases for objects as keys in a map, and it is expected that you will hold a reference to it if you want to access it. You can see this in action here: https://searchfox.org/mozilla-central/rev/94d7c959115c03ea1e9406d6105b36cabe63775d/browser/components/extensions/parent/ext-devtools.js#197,217 -- Objects change over time, so transforming an object into a string representation will result in the key and the actual object getting out of sync -- leading to a loss of access to the values without some synchronization point.  Otherwise, you need to do some form of mapping it to some identifier. 

When you are using an object as a key in a map, it is because you are mapping related information to that specific object. The same applies to groupByToMap.

Back to Bug 1739648 Comment 16