Created
December 14, 2017 13:20
-
-
Save thomasxbanks/a35b927e53a23e4c5b94d733ff472ab7 to your computer and use it in GitHub Desktop.
turns nodeLists into arrays to make forEach work in IE11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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