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 point length implying metric topology. david's suggestion of count nice. istm we're talking cardinality, no need silly w/ precision. though size fine me, , has plenty of prior art.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -