Skip to content

Instantly share code, notes, and snippets.

@thiagotpc
Created February 28, 2016 13:57
Show Gist options
  • Save thiagotpc/a6a6e330e1419cce3cb9 to your computer and use it in GitHub Desktop.
Save thiagotpc/a6a6e330e1419cce3cb9 to your computer and use it in GitHub Desktop.
Add array methods to NodeList
var arrayMethods = Object.getOwnPropertyNames( Array.prototype );
arrayMethods.forEach( attachArrayMethodsToNodeList );
function attachArrayMethodsToNodeList(methodName)
{
if(methodName !== "length") {
NodeList.prototype[methodName] = Array.prototype[methodName];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment