W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2011

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

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Fri, 23 Dec 2011 22:38:45 -0500
Message-ID: <4EF54945.6060704@mit.edu>
To: Jake Verbaten <raynos2@gmail.com>
CC: "Marat Tanalin | tanalin.com" <mtanalin@yandex.ru>, www-dom@w3.org
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:09 GMT