Skip to content

Instantly share code, notes, and snippets.

@marcinantkiewicz
Created January 2, 2022 22:47
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 marcinantkiewicz/56da1b7fadec3dfccbc51bee2c914a7d to your computer and use it in GitHub Desktop.
Save marcinantkiewicz/56da1b7fadec3dfccbc51bee2c914a7d to your computer and use it in GitHub Desktop.
// note: document.get_elementByTagName returns HTMLCollection which is not an array, and does not implement foreach().
// ... turns htmlcolleciton into an array. Array.from(a) would do same here.
// This also an example of design decision that did not age well.
// ref: https://stackoverflow.com/questions/22754315/for-loop-for-htmlcollection-elements/22754453 or so.
[...document.getElementsByTagName('img')].forEach(a=>console.log(a.style.visibility='hidden'))
[...document.getElementsByTagName('img')].forEach(a=>console.log(a.style.height='100px'))
[...document.getElementsByTagName('img')].forEach(a=>my_function(a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment