Re: toArray() method for array-like DOM list objects

On 12/23/11 8:09 PM, Jake Verbaten wrote:
> To add to the conversation. A recent jsperf
> http://jsperf.com/toarray-vs-slice shows that toArray and slice.call
> have similar levels of performance depending on array sizes.

For what it's worth, this is also passing Arrays to both toArray and 
slice.call, not nodelists.  The performance characteristics can be 
pretty different (e.g. slice() has a fast-path for dense arrays in 
SpiderMonkey that just does a single memcpy).

> And I believe es.next will have Array.from (
> https://mail.mozilla.org/pipermail/es-discuss/2011-July/015831.html )
> which is basically an official readable method to turn an array like
> into an array.

That seems like the way to go to me.

-Boris

Received on Saturday, 24 December 2011 03:39:30 UTC