New ES6 strawman: Array.prototype.fill and Array.prototype.move

Tab Atkins Jr. jackalmage at gmail.com
Sun Jun 23 18:25:03 PDT 2013


On Sun, Jun 23, 2013 at 1:36 PM, Brendan Eich <brendan at mozilla.com> wrote:
> Q: Does anyone know of a rationale for why (start, end) might be a better
> design pattern than (start, count) for such operation?
>
> A: Array.prototype.slice uses (start, end) where end is a fencepost to
> facilitate looping over half-open ranges within a larger range. Spec’ing
> count requires subtracting next_start - end, gratuitously. Also, consistency
> with slice and range APIs matters. This should be considered carefully in
> the design.

In sane designs, start/end is better because you can specify negative
indexes for either argument.  Very useful.  There is no analog of this
for start/count.

Also, I use .slice() a lot, and consistency with that would be great.
Inconsistency between start/end and start/count is one of the (many)
reasons I hate PHP.

~TJ


More information about the es-discuss mailing list