2 ms·
Indeed. Though still, NodeList has the length property with which you can check for "emptiness" the same as with an array, that's what I meant to say. Speaking
by maga 10y ago
Indeed. Though still, NodeList has the length property with which you can check for "emptiness" the same as with an array, that's what I meant to say.
Speaking of which, there are few features in ES2015 that make NodeList more palatable:
1. Iterables. NodeList is iterable and you can use, among others, the for..of construction to iterate over its content.
2. There is the Array.from method for turning array-like objects into true arrays. Not much different from our usual method of calling [].slice.call in this particular case, yet it's a bit shorter, standardized, and has a few additional perks, like accepting map function as the second argument.