实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
AخA
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <title>Object.getOwnPropertyNames() Example</title>
5
    <script type="text/javascript">
6
    
7
        function Person(){
8
        }
9
        
10
        Person.prototype.name = "Nicholas";
11
        Person.prototype.age = 29;
12
        Person.prototype.job = "Software Engineer";
13
        Person.prototype.sayName = function(){
14
            alert(this.name);
15
        };
16
        
17
        var keys = Object.getOwnPropertyNames(Person.prototype);
18
        alert(keys);   //"constructor,name,age,job,sayName"
19
        
20
    </script>
21
</head>
22
<body>
23
<p>Note: this example only works in browsers that have implemented the ECMAScript 5 <code>Object.defineProperty()</code> method (IE9, Firefox 4, and Chrome 7).</p>
24
</body>
25
</html>