Skip to content

Instantly share code, notes, and snippets.

@BenoitZugmeyer
Created December 17, 2014 16:01
Show Gist options
  • Save BenoitZugmeyer/8005839623fb5a029a94 to your computer and use it in GitHub Desktop.
Save BenoitZugmeyer/8005839623fb5a029a94 to your computer and use it in GitHub Desktop.
NodeList Array
Object.getOwnPropertyNames(Array.prototype).forEach(function (name) {
if (!(name in NodeList.prototype))
Object.defineProperty(NodeList.prototype, name, Object.getOwnPropertyDescriptor(Array.prototype, name));
});
/* ... */
/* Profit! */
document.querySelectorAll('div').slice(3, 10);
document.body.childNodes.reduce(function (total, el) { return total + el.offsetHeight; }, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment