ecmascript 6 - Why do JavaScript Sets/Maps use `size` instead of `length`? -
while looking on new changes javascript noticed set
, map
use .size
instead of .length
arrays would.
this seems pointless diversion what's normal arrays - 1 more thing remember.
was there design reason this?
there's lot of discussion in esdiscuss thread "set length property". hotly debated issue, it's not surprising not agree resolution.
there tremendous amount of arguing in esdiscuss. ultimately, argument prevailed (as evidenced fact es2015's sets have size
, not length
) summarized in a post david bruant:
...for me 'length' refers measurement ruler. start @ 0 , see goes. accurate array indexed set (starting @ 0 , growing) , arrays considered in c (continuous sequence of bytes) ecmascript arrays seem inspired of. less relevant unordered collections such sets i'd tend consider messy bag.
and further discussed in a post dean landolt:
just wanted jump in , non-writable
length
consistent string behavior well, david makes pointlength
implying metric topology. david's suggestion ofcount
nice. istm we're talkingcardinality
, no need silly w/ precision. thoughsize
fine me, , has plenty of prior art.
Comments
Post a Comment