Nick Krempel (2014-02-22T03:50:49.000Z)
A sparse array is useful whenever the index represents an externally
meaningful piece of data (like an ID).

This use case could be replaced with a Map which just uses integer keys,
but I believe JavaScript engines are better optimized working with Arrays
here, where the keys are known to be integers. So in some cases when you
care about performance, you may want to use a sparse array. (For some
JavaScript engines and some ranges of array size you may in fact be better
off with a dense array for performance, even if it means spending time
filling it with undefined. That may not be an option if 'undefined' is a
meaningful value differing from missing.)

Nick



On 21 February 2014 21:50, C. Scott Ananian <ecmascript at cscott.net> wrote:

> I actually just responded in more depth over at
>
> http://esdiscuss.org/topic/what-does-is-not-present-mean-in-spec-algorithms#content-9
>
> Let's continue the discussion over there.
>  --scott
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140222/c972d441/attachment.html>
domenic at domenicdenicola.com (2014-03-02T22:42:42.149Z)
A sparse array is useful whenever the index represents an externally
meaningful piece of data (like an ID).

This use case could be replaced with a Map which just uses integer keys,
but I believe JavaScript engines are better optimized working with Arrays
here, where the keys are known to be integers. So in some cases when you
care about performance, you may want to use a sparse array. (For some
JavaScript engines and some ranges of array size you may in fact be better
off with a dense array for performance, even if it means spending time
filling it with undefined. That may not be an option if 'undefined' is a
meaningful value differing from missing.)