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

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

From: Jake Verbaten <raynos2@gmail.com>
Date: Sat, 24 Dec 2011 02:09:57 +0100
Message-ID: <CAMCMjp23WjV___RuygPcf6TSn=GF=wix-=5ziUeCtWbALxOBzQ@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: "Marat Tanalin | tanalin.com" <mtanalin@yandex.ru>, www-dom@w3.org
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.

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.

However as a web developer, I will add that the most common utility
function I use when working with the DOM is a toArray function. I use a
toArray function becuase "what does slice.call do?" is a common question.
Received on Saturday, 24 December 2011 01:10:33 GMT

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