Nest all content into snippets
This commit is contained in:
20
snippets/js/s/node-list-to-array.md
Normal file
20
snippets/js/s/node-list-to-array.md
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
title: NodeList to array
|
||||
type: snippet
|
||||
language: javascript
|
||||
tags: [browser,array]
|
||||
cover: colors-mural
|
||||
dateModified: 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.
|
||||
|
||||
```js
|
||||
const nodeListToArray = nodeList => [...nodeList];
|
||||
```
|
||||
|
||||
```js
|
||||
nodeListToArray(document.childNodes); // [ <!DOCTYPE html>, html ]
|
||||
```
|
||||
Reference in New Issue
Block a user