On Tue, Jan 3, 2012 at 3:34 AM, Mariusz Nowak < [email protected]> wrote:
> > > Rick Waldron 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. > >> > > > > Is the controversy editorial or fact, because the following methods are > > all > > specified to use a temporary, newly initialized Array internally: > > > > Array.prototype.concat > > Array.prototype.filter (...) > > > > Rick, you say that apart of output arrays this methods create some other > temporary arrays internally ? > I don't see anything like that in specification, where exactly is it stated > ? > Array.prototype.concat - http://es5.github.com/#x15.4.4.4 #2 Array.prototype.filter - http://es5.github.com/#x15.4.4.20 #6 Array.prototype.map - http://es5.github.com/#x15.4.4.19 #6 Array.prototype.slice - http://es5.github.com/#x15.4.4.10 #2 Array.prototype.splice - http://es5.github.com/#x15.4.4.12 #2 String.prototype.match - http://es5.github.com/#x15.5.4.10 #8b String.prototype.split - http://es5.github.com/#x15.5.4.14 #3 RegExp.prototype.exec - http://es5.github.com/#x15.10.6.2 #13 Object.getOwnPropertyNames - http://es5.github.com/#x15.2.3.4 #2 Object.keys - http://es5.github.com/#x15.2.3.14 #3 > > > > This doesn't produce the same as Array.prototype.repeat.. > > > > // regular > > console.log( Array.generate( 3, [1,2,3] ) ); > > // sparse > > console.log( Array.generate( 3, [1,2,,3] ) ); > > > > [ [ 1, 2, 3 ], [ 1, 2, 3 ], [ 1, 2, 3 ] ] > > [ [ 1, 2, , 3 ], [ 1, 2, , 3 ], [ 1, 2, , 3 ] ] > > > > It is supposed to be used that way: > Array.generate(4, 1, 2, 3) // -> [1, 2, 3, 1]; > Got it, I misunderstood, as there was no example usage - thanks for clarifying. Rick > > Usage you suggested as with Array.prototype.repeat will imply need of > creating temporary array object. > > -- > Mariusz Nowak > https://github.com/medikoo > > > ----- > Mariusz Nowak > > https://github.com/medikoo > -- > View this message in context: > http://old.nabble.com/Suggestion%3A-Array.prototype.repeat-tp33067649p33070367.html > Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at > Nabble.com. > > _______________________________________________ > 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

