Array.range() (was: Suggestion: Array.prototype.repeat)

Maël Nison nison.mael at gmail.com
Tue Jan 3 10:25:19 PST 2012


> Good point. Maybe all of these parameters should be options:
>
> Array.range() -> 0, 1, 2, 3, ...
> Array.range({ start: 3 }) -> 3, 4, 5, 6, ...
> Array.range({ end: 5 }) -> 0, 1, 2, 3, 4
> Array.range({ step: 3 }) -> 0, 3, 6, 9, ...
> Array.range({ start: -2, step: -1 }) -> -2, -3, -4, -5, ...
> etc.

Why use a new syntax for a simple function call ?
Afaik, there is no other standard function using an object for passing
parameters, is it ?

On 3 January 2012 18:42, Axel Rauschmayer <axel at rauschma.de> wrote:
> I think it's fairly common for range implementations to provide an optional
> `step` parameter
>
>
> [...]
>
> The defaults of start and end and the comparison operator depend on the sign
> of step.
>
> --
> Dr. Axel Rauschmayer
> axel at rauschma.de
>
> home: rauschma.de
> twitter: twitter.com/rauschma
> blog: 2ality.com
>
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
Maël Nison
Epitech 2014, Paris - Astek


More information about the es-discuss mailing list