Sometimes, we want to filter or map nodelists in JavaScript.
In this article, we’ll look at how to filter or map nodelists in JavaScript.
How to filter or map nodelists in JavaScript?
To filter or map nodelists in JavaScript, we can use the spread operator.
For instance, we write
const arr = [...nodelist];
to convert the nodelist
to an array with the spread operator.
Then we can call map
or filter
on it to do the mapping or filtering like any other array.
Conclusion
To filter or map nodelists in JavaScript, we can use the spread operator.