JavaScript高级程序设计(第三版) 8章

2018-10-17  本文已影响0人  ft207741

Menu


第8 章 BOM

8.1 window对象
    var age = 29;
    window.color = "red";
    //在 IE < 9 时抛出错误,在其他所有浏览器中都返回 false
    // var 声明的windows属性有一个名为[[Configurable]]的特性,这个特性的值被设置为false,因此这样定义的属性不可以通过delete 操作符删除。
    delete window.age;
    //在 IE < 9 时抛出错误,在其他所有浏览器中都返回 true
    delete window.color; //returns true
    document.write(window.age); //29
    document.write(window.color); //undefined
    //这里会抛出错误,因为 oldValue 未定义
    var newValue = oldValue;
    //这里不会抛出错误,因为这是一次属性查询
    var newValue = window.oldValue;
    document.write(newValue)  //undefined

page 214


上一篇 下一篇

猜你喜欢

热点阅读