Matías Fidemraizer Matías Fidemraizer - 3 years ago 84
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download