Nick Krempel (2014-02-22T04:01:40.000Z)
domenic at domenicdenicola.com (2014-03-02T22:43:23.258Z)
And here's another sort of case where sparse arrays are useful, a more concrete example: A partial application function which takes a function (as the 'this' argument in this example) and a (sparse) array specifying which parameters to bind: `f.partial(['a', , 'b'])` is then different from `f.partial(['a', undefined, 'b'])` in that the former binds 'a' to the first parameter and 'b' to the third parameter (leaving the second parameter unbound), while the latter binds 'a' to the first parameter, undefined to the second parameter, and 'b' to the third parameter. You could use an object like `{0: 'a', 2: 'c'}` but this is clearly clunkier syntax (and likely a problem in performance-critical code too, as number->string conversions are happening in many engines here). You could use a Map with only integer keys, but this is also clunky and is more weakly typed in that non-integer keys potentially have to be checked for.