Skip to content

Instantly share code, notes, and snippets.

@thomasxbanks
Created December 14, 2017 13:20
Show Gist options
  • Select an option

  • Save thomasxbanks/a35b927e53a23e4c5b94d733ff472ab7 to your computer and use it in GitHub Desktop.

Select an option

Save thomasxbanks/a35b927e53a23e4c5b94d733ff472ab7 to your computer and use it in GitHub Desktop.
turns nodeLists into arrays to make forEach work in IE11
let paragraphs = [].slice.call(document.querySelectorAll('p'))
paragraphs.forEach((paragraph)=>{
// Do something to each paragraph
})
// The trick is the [].slice.call() wrapper that is shorthand for accessing the Array.prototype
// https://davidwalsh.name/nodelist-array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment