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 ]
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 ]