Categories
JavaScript Answers

How to filter or map nodelists in JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *