|
|
|
|
|
by radarsat1
3263 days ago
|
|
Those all sort of make sense to me. 'foo' is a string and can be iterated over. 42 is a number that can be provided to a function. Not sure about this one tbh. Could be useful for passing a number to a function if-and-only-if the number is valid (not NAN) WeakMap(), I don't know what it is but I assume it's a map that can be iterated over. mapping 'false' would fit well the Maybe monad. |
|
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.