Sets plus JSON

Brendan Eich brendan at mozilla.org
Wed Oct 3 12:36:12 PDT 2012


Rick Waldron wrote:
> On Wed, Oct 3, 2012 at 2:04 PM, Rick Waldron <waldron.rick at gmail.com 
> <mailto:waldron.rick at gmail.com>> wrote:
>
>
>
>     On Wed, Oct 3, 2012 at 1:43 PM, Brandon Benvie
>     <brandon at brandonbenvie.com <mailto:brandon at brandonbenvie.com>> wrote:
>
>         Another options for Maps is to represent them as an array of
>         [key, value].
>
>
>     Which is a rough approximation of what a Map looks like internally.
>
>
>
> Sorry, this is incorrect. Map looks more like:
>
> [key1, key2]
> [value1, value2]
>
> Sorry for confusion

As an implementation in ES5, maybe (O(n) lookup cost). But the thing to 
aim for is the shape of the Map parameter, and that looks like

[[key1, value1], [key2, value2]]

Still need type tagging to revive as a Map, of course.

JSON object notation can't handle Map, though: key can be any value 
(ignore JSON not handling all JS values).

/be


More information about the es-discuss mailing list