Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tomhodgins
Created December 2, 2018 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomhodgins/4c557392138f934180b1d58aad101101 to your computer and use it in GitHub Desktop.
Save tomhodgins/4c557392138f934180b1d58aad101101 to your computer and use it in GitHub Desktop.
// add map, filter, reduce to NodeList
[
'map',
'filter',
'reduce',
'includes',
'every',
'some'
].forEach(method =>
NodeList.prototype[method] = Array.prototype[method]
)
// Logging
l = log = console.log
d = dir = console.dir
g = group = (name, ...strings) => {
console.group(name)
strings.forEach(string => console.log(string))
console.groupEnd()
}
// Finding elements
q = qsa = document.querySelectorAll.bind(document)
qs = document.querySelector.bind(document)
// Adding event listeners
ael = window.addEventListener.bind(window)
Node.prototype.ael = Node.prototype.addEventListener
NodeList.prototype.ael = function() {
this.forEach(node => node.ael(...arguments))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment