Files
30-seconds-of-code/snippets/nodeListToArray.md
2022-12-04 22:20:49 +02:00

426 B

title, tags, cover, firstSeen, lastUpdated
title tags cover firstSeen lastUpdated
NodeList to array browser,array blog_images/colors-mural.jpg 2018-05-06T18:11:21+03:00 2020-10-21T21:54:53+03:00

Converts a NodeList to an array.

  • Use spread operator (...) inside new array to convert a NodeList to an array.
const nodeListToArray = nodeList => [...nodeList];
nodeListToArray(document.childNodes); // [ <!DOCTYPE html>, html ]