|
|
|
|
|
by kevincennis
3263 days ago
|
|
But what are the own properties of a number? There's nothing to iterate, and therefore nothing to map. WeakMap is a new-ish type whose keys are objects. The references to those objects are weakly held, which means that an object `x` whose only reference is a WeakMap key will still be eligible for garbage collection. They are non-iterable for exactly that reason. Also: how do you iterate over `false` or a function? What about user-created classes? There are so many cases where the behavior would either be nonsensical or at least unintuitive that (in my personal and completely subjective opinion) they outweigh the slight convenience of being able to "map" a plain old JavaScript object. |
|
Granted, in JavaScript maybe this wouldn't make sense.