Object.getOwnPropertyNames()方法

2017-06-21 11:20:00
admin
原创
597
<!DOCTYPE html>
<html>
<head>
    <title>Object.getOwnPropertyNames() Example</title>
    <script type="text/javascript">
    
        function Person(){
        }
        
        Person.prototype.name = "Nicholas";
        Person.prototype.age = 29;
        Person.prototype.job = "Software Engineer";
        Person.prototype.sayName = function(){
            alert(this.name);
        };
        
        var keys = Object.getOwnPropertyNames(Person.prototype);
        alert(keys);   //"constructor,name,age,job,sayName"
        
    </script>
</head>
<body>
<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>
</body>
</html>
  • QQ讨论群
  • 关注微信
    • 欢迎咨询
    • 欢迎加入QQ群 16506021
  • 公众号:源宝网络