It would be conveniently consistent if collection-like objects could all return their number of items from a size
property.
set = Set([
'What did Yoda say when he saw himself in 4K?',
'HDMI.'
])
arr = Array.from(set)
arr.size === set.size // 2 true it is
Downsides from my limited perspective:
- Two properties (
length
andsize
) for the same thing. - Possible conflicts with ancient user land libraries?
- Derails false-etamology-like explanations I’ve invented to justify the difference outside “because time and Java”.
Alternatives from my limited perspective:
- Something like
Symbol.size
that does the same thing, tho it may offer little over a userland helper pattern.