Suggestion: Array.prototype.repeat

Adam Shannon adam at
Mon Jan 2 14:55:01 PST 2012

Another thing to think about is that .repeat (both on String and
Array) will be used a lot in production. So it would make sense for
each solution to be optimized for their specific case. It doesn't make
sense to slow down something as trivial as .repeat()

On Mon, Jan 2, 2012 at 16:51, Michael A. Smith <michael at> wrote:
> On Mon, Jan 2, 2012 at 3:56 PM, Mariusz Nowak
> < at> wrote:
>> I like it, it indeed looks very logical, however it's a bit controversial
>> that we need to create temporary array object to get one that we want.
>> Function (not method) that returns generated array may make more sense…
> Is the difference in overhead between instantiating a new array and
> using on arguments really worth sacrificing
> consistency with the proposed string.prototype.repeat and the very
> clean syntax of someArray.repeat(n)?
> Michael A. Smith
> Web Developer
> True Action Network (an eBay company)
> _______________________________________________
> es-discuss mailing list
> es-discuss at

Adam Shannon
Web Developer
University of Northern Iowa
Sophomore -- Computer Science B.S. & Mathematics

More information about the es-discuss mailing list