have a length property, can be indexed like arrays.
can loop with traditional for( ; ; ) loop, for-of loop, forEach() method.
can convert into array with Array.from().
Some older browsers have not implementedNodeList.forEach()norArray.from(). This can be circumvented by using 👉 💈範例
::first-line and ::first-letterpseudo-elements match portions of text nodes rather than actual elements, they will not match if used with querySelectorAll() or querySelector().
many browsers will refuse to return matches for the :link and :visitedpseudo-classes.
// ⭐️ traditional for-loop
for (let i = 0; i < nodeList.length; i++) {
let node = nodeList[i];
}
// ⭐️ for-of loop
const list = document.querySelectorAll('input[type=checkbox]');
for (let checkbox of list) {
checkbox.checked = true;
}
// ⭐️ for browsers which don't support NodeList.forEach()
Array.prototype.forEach.call(list, (checkbox) => {
checkbox.checked = true;
});