所有在全局作用域中声明的变量、函数都会变成window 对象的属性和方法

2017-06-16 15:14:00
admin
原创
496
<!DOCTYPE html>
<html>
<head>
    <title>Delete Operator Example</title>
</head>
<body>
    <p>Hello world!</p>
    <script type="text/javascript">

        var age = 29;
        window.color = "red";
        
        //throws an error in IE < 9, returns false in all other browsers
        delete window.age;

        //throws an error in IE < 9, returns true in all other browsers
        delete window.color;    //returns true
        
        alert(window.age);      //29
        alert(window.color);    //undefined

    </script>
</body>
</html>
  • QQ讨论群
  • 关注微信
    • 欢迎咨询
    • 欢迎加入QQ群 16506021
  • 公众号:源宝网络