Skip to content

Instantly share code, notes, and snippets.

@sapslaj
Created November 10, 2016 16:17
Show Gist options
  • Select an option

  • Save sapslaj/4d98e0713b4c207393d10326095d1f8f to your computer and use it in GitHub Desktop.

Select an option

Save sapslaj/4d98e0713b4c207393d10326095d1f8f to your computer and use it in GitHub Desktop.
Hack NodeList to use toArray() so you can then use forEach and stuff. Don't use it unless you are a lazy dirtbag though.
// Don't do this.
NodeList.prototype.toArray = function () {
var newArray = [];
for (var i = 0; i < this.length; i++) {
newArray.push(this[i]);
}
return newArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment