4 DOM 对象深入分析
4.1 元素对象的原型链关系
div元素 -> HTMLDivElement.prototype -> HTMLElement.prototype -> Element.prototype -> EventTarget.prototype -> Object.prototype
4.2 事件对象的原型链关系
鼠标事件对象 -> MouseEvent.prototype -> UIEvent.protptype -> Event.prototype -> Object.prototype
4.3 HTMLCollection 和 NodeList 的区别
① HTMLCollection 对象
1. getElementsByTagName()、getElementsByClassName()、元素.children、document.all 这些方式获取 HTMLCollection 类型的集合
2. HTMLCollection 中从成员必须都是元素
3. HTMLCollection 是动态的集合,在获取集合之后,如果dom结构中新增满足条件的元素,会自动更新到集合中。
4. 没有 forEach 方法
② NodeList
1. querySelectorAll()、getElementsByName()、元素.childNodes 这些方式获取 NodeList 类型的集合
2. NodeList 中的成员可以任何类型的节点
3. NodeList 是静态的结合,获取的时候有哪些元素就永远有哪些元素
4. 有 forEach 方法