Matías Fidemraizer Matías Fidemraizer - 9 months ago 44
Javascript Question

Is Set a hashed collection in JavaScript?

I was asking myself this question. Is

a hashed collection in JavaScript?

For example,
will iterate the entire
or do its implementations use an internal hash table to locate an item within the collection?


The ECMAScript 2015 specification says that:

Set objects must be implemented using either hash tables or other mechanisms that, on average, provide access times that are sublinear on the number of elements in the collection.

Obviously they can't force a particular JS engine to actually do that, but in practice JS engines will do the right thing.