Files
30-seconds-of-code/snippets/nodeListToArray.md
Angelos Chalaris 611729214a Snippet format update
To match the starter (for the migration)
2019-08-13 10:29:12 +03:00

16 lines
310 B
Markdown

---
title: nodeListToArray
tags: browser,array,beginner
---
Converts a `NodeList` to an array.
Use spread operator inside new array to convert a `NodeList` to an array.
```js
const nodeListToArray = nodeList => [...nodeList];
```
```js
nodeListToArray(document.childNodes); // [ <!DOCTYPE html>, html ]
```