实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <title>Data Properties Example</title>
5
    <script type="text/javascript">
6
7
        var person = {};
8
        Object.defineProperty(person, "name", {
9
            configurable: false,
10
            value: "Nicholas"
11
        });
12
        
13
        alert(person.name);
14
        delete person.name;
15
        alert(person.name);
16
17
    </script>
18
</head>
19
<body>
20
    <p>Note: this example only works in browsers that have implemented the ECMAScript 5 <code>Object.defineProperty()</code> method (IE9 and Firefox 4).</p>
21
</body>
22
</html>