Map/Set.prototype.size is O(n)

Daniel Herman daniel.c.herman at
Wed Mar 29 15:15:45 UTC 2017

In reading the relevant section for the `size` accessors (http://www.ecma-, I'm
confused and wondering why this was defined as an O(n) operation in the
`get` accessor rather than as an additional step in the `set`, `delete`,
and `clear` methods to track an internal `[[Size]]` variable or something,
making the public `size` accessor capable of being O(1).

It seems surprising to me that in order to be spec compliant, Map and Set
implementations must implement accessors that have surprising perf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list