Re:TC39: Add Object.groupBy and Map.groupBy
by zeroimpl on Tuesday December 19, 2023 @06:22PM
(#38703358)
The part I’m confused on is the documentation saying the returned object from Object.groupBy doesn’t extend from Object.prototype. Is it still an object?
[ Parent
| on HN ]
Re:TC39: Add Object.groupBy and Map.groupBy
by edflsafoiewq on Tuesday December 19, 2023 @06:28PM
(#38703420)
It's called a null-prototype object: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
They're "usually used as a cheap substitute for maps": the lack of prototype prevents the object from being polluted by keys that morally shouldn't be there, like toString, etc.
Re:TC39: Add Object.groupBy and Map.groupBy
by aragonite on Tuesday December 19, 2023 @06:44PM
(#38703570)
It's a value that belongs as a member of the Object data type (Object(it)===it), but it's not (in addition) an instance of the Object constructor (!(it instanceof Object)). I guess the former, wider sense of 'an object' is more often intended.