Map/Set.prototype.size

Tab Atkins Jr. jackalmage at gmail.com
Fri Oct 12 12:18:29 PDT 2012


On Fri, Oct 12, 2012 at 12:14 PM, Erik Arvidsson
<erik.arvidsson at gmail.com> wrote:
> On Fri, Oct 12, 2012 at 11:16 AM, David Bruant <bruant.d at gmail.com> wrote:
>> Firefox has implement a Map/Set.prototype.size *method* to query the number
>> of mapping/elements.
>> It's not in the strawman. It appears in the latest draft, though weirdly
>> enough Map.prototype.size is a function with an unused argument.
>> What about making it an getter instead of a function? I guess we also don't
>> need the extra parens to request for Map#keys, Map#values, Map#items.
>
> For keys, values and items I think they are cleaner as methods since
> they return a new iterator every time.
>
> If they were properties, I would expect the following to always be true:
>
> map.items === map.items

Agreed, I expect things that look like properties to be stable.
Factories should be methods.

~TJ


More information about the es-discuss mailing list