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

Michał Wadas michalwadas at
Wed Mar 29 15:29:18 UTC 2017

Implementations aren't required to follow exactly these steps, just to
have the same result.

On 29/03/17 17:15, Daniel Herman wrote:
> In reading the relevant section for the `size` accessors
> (
> <>),
> 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
> implications.
> _______________________________________________
> es-discuss mailing list
> es-discuss at

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list