Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0
Firefox 119
Windows
Desktop
one year ago
Test name Executions per second
Array.prototype.slice on NodeList 14880080.0 Ops/sec
Array.prototype.concat on NodeList 9067304.0 Ops/sec
Array.from on NodeList 147007.5 Ops/sec
Spread on NodeList 148772.9 Ops/sec
HTML Preparation code:
AخA
 
1
<ul>
2
</ul>
Script Preparation code:
x
 
var fooSet = new Set();
var ul = document.querySelector('ul');
for(var i=0;i<100;i++) {
  fooSet.add(i);
  ul.appendChild(document.createElement('li'));
}
var listItems = document.querySelectorAll('li');
Tests:
  • Array.prototype.slice on NodeList

     
    var other = [].slice.call(fooSet);
  • Array.prototype.concat on NodeList

     
    var other = [].concat.call([],fooSet);
  • Array.from on NodeList

     
    var other = Array.from(listItems);
  • Spread on NodeList

     
    var other = [...listItems];