image.png

    DOM collections are read-only
    DOM collections, and even more – all navigation properties listed in this chapter are read-only.
    We can’t replace a child by something else by assigning childNodes[i] = ....
    Changing DOM needs other methods. We will see them in the next chapter.

    Don’t use for..in to loop over collections
    Collections are iterable using for..of. Sometimes people try to use for..in for that.
    Please, don’t. The for..in loop iterates over all enumerable properties. And collections have some “extra” rarely used properties that we usually do not want to get:

    for…of 走的是iterator,for…in走的是 可枚举property.
    children: 走的是element node
    childNodes: 走的是node