Fastest way to convert JavaScript NodeList to Array?

前端 未结 13 1885
清酒与你
清酒与你 2020-11-22 16:48

Previously answered questions here said that this was the fastest way:

//nl is a NodeList
var arr = Array.prototype.slice.call(nl);

In benc

13条回答
  •  暖寄归人
    2020-11-22 17:45

    The results will completely depend on the browser, to give an objective verdict, we have to make some performance tests, here are some results, you can run them here:

    Chrome 6:

    Firefox 3.6:

    Firefox 4.0b2:

    Safari 5:

    IE9 Platform Preview 3:

提交回复
热议问题