Skip to content

Instantly share code, notes, and snippets.

@vincentorback
Created March 20, 2016 12:00
Show Gist options
  • Save vincentorback/e766a15d58a5c1738c64 to your computer and use it in GitHub Desktop.
Save vincentorback/e766a15d58a5c1738c64 to your computer and use it in GitHub Desktop.
Converting a NodeList to an Array
/**
* 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