ES3 quasi incompatibilities

Yuh-Ruey Chen maian330 at
Sun Nov 11 19:18:31 PST 2007

Garrett Smith wrote:
> JavaScript does not provide basic functionality for unique collections.

It's trivial to implement an efficient Set class even in ES3 (with
certain restrictions on the "type" of the key) - just use objects which
are pretty much specialized hash tables (maps from string to values,
keys collides with prototype keys). For ES4, we have maps which are hash
tables as bareboned as you'll get in the language. I'm not sure why you
have all those |!Map.containsKey(lisx[i])| checks in your Map example,
since they're totally unnecessary.

A SortedSet is a bit trickier, because that would require some sort of
binary search tree to be efficient. But it can be done.

More information about the Es4-discuss mailing list