重读红宝书

58 阅读1分钟

- 一、<script>元素有以下八个属性

    • defer: 表示脚本可以延迟到文档完全被解析和显示之后再执行,在domContentLoad之前执行
    • async: 脚本在loaded事件之前,执行顺序不确定,建议使用defer

    二、 数据类型6种: typeof 操作符

    • (typeof null === 'object'):null被认为是空对象的引用
    • (typeof age === undefine)typeof为初始化的值为undefine
    • 对象的空引用使用null,而字面量声明声明ingundefine

三、 垃圾回收: 对于全局变量,在不需要的时候应该手动置为null

四、判断原型上的方法

 function hasPrototypeProperty(obj, name){
     ruturn !obj.hasOwnProperty(name) && (name in object)
 }

五、document.location === window.location 六、dom树遍历

const i = document.createNodeIterator(document)
let node = i.nextNode()
while(node !== null) {
 node = i.nextNode()
 console.log(node)
}
// treeWalker