Filter or map nodelists in ES6

前端 未结 4 1949
没有蜡笔的小新
没有蜡笔的小新 2020-12-12 20:10

What is the most efficient way to filter or map a nodelist in ES6?

Based on my readings, I would use one of the following options:

[...nodelist].filt         


        
4条回答
  •  庸人自扰
    2020-12-12 20:44

    I found a reference that uses map directly on the NodeList by

    Array.prototype.map.call(nodelist, fn)
    

    I haven't tested it, but it seems plausible that this would be faster because it should access the NodeList directly.

提交回复
热议问题