Rick Waldron wrote:
> 
> On Mon, Jan 2, 2012 at 3:56 PM, Mariusz Nowak <
> medikoo+mozilla....@medikoo.com> 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
?



> 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];

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
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to