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 ]