jaandrle / jaandrle.github.io

Personal page/blog
https://jaandrle.github.io/
MIT License
2 stars 3 forks source link

Typy `DOM` kolekcí #51

Closed jaandrle closed 3 years ago

jaandrle commented 3 years ago

Rozcestník

Different kinds of DOM collections: – Static NodeList [1]: .querySelectorAll() – Live NodeList [1]: .childNodes – HTMLCollection—always live [2]: .getElementsByClassName(), .getElementsByTagName()

[1] https://t.co/RVYdbwxU5i [2] https://t.co/TIo4Fsyb4c

Viz Axel Rauschmayer on Twitter.

Iterace


document.forms
//= HTMLCollection []
document.forms.forEach
//= undefined
document.body.childNodes
//= NodeList(3) [text, div.content, text]
document.body.childNodes.forEach
//= ƒ forEach() { [native code] }
document.querySelectorAll("form")
//= NodeList []
document.querySelectorAll("form").forEach
//= ƒ forEach() { [native code] }