On Mon, Jan 2, 2012 at 5:55 PM, Adam Shannon <[email protected]> wrote:
> 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() > Creating a 10000 item array by repeating a 1000 item array 10 times, the difference is negligible when compared the implementation that I wrote, not the one given above http://jsperf.com/array-repeat/2 Also, note that I had to "make up" my own Array.repeat() because the Array.generate shown above did not create the same return as the initial Array.prototype.repeat(), but I stuck to the concepts laid out - no new array is initialized (except that Array.prototype.slice _does_ initialize a new Array() ). Rick > > On Mon, Jan 2, 2012 at 16:51, Michael A. Smith <[email protected]> > wrote: > > On Mon, Jan 2, 2012 at 3:56 PM, Mariusz Nowak > > <[email protected]> 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 Array.prototype.slice.call 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 > > [email protected] > > https://mail.mozilla.org/listinfo/es-discuss > > > > -- > Adam Shannon > Web Developer > University of Northern Iowa > Sophomore -- Computer Science B.S. & Mathematics > http://ashannon.us > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

