3 ms·
As of ES2015 you can convert an iterable like HTMLCollection into a regular array by using the spread syntax: [...iterable]
by TheAceOfHearts 8y ago
As of ES2015 you can convert an iterable like HTMLCollection into a regular array by using the spread syntax:
[...iterable]
- pietro 8y agoThat, or `Array.from`. You can even create an array from a string: Array.from('string') [...'string']
- venning 8y agoYou have always been able to convert them with: Array.prototype.slice.call(htmlCollection); Which has been the canonical way to cast them. But it will still throw on null or undefined.