Created
March 20, 2016 12:00
-
-
Save vincentorback/e766a15d58a5c1738c64 to your computer and use it in GitHub Desktop.
Converting a NodeList to an Array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Turns a list of nodes into an array | |
* @param { NodeList } nodeList | |
* @return { Array } | |
*/ | |
export function nodesToArray(nodeList) { | |
return [...nodeList]; | |
return Array.from(nodeList); | |
return [].slice.call(nodeList); | |
return Array.prototype.slice.call(nodeList); | |
} | |
/* Pick one, depending on how cool you are... */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment