function Person (sex){ this.sex = sex;}Person.prototype.name = 'xiaoming';Person.prototype.sayName = function(){ console.log(this.name)};let person1 = new Person('man');person1.age = 24;person1.job = 'chengxuyuan';Object.defineProperty(person1, "height", {value:185, enumerable:false});//Object.keys() 返回一个数组,包含对象自身及构造函数的所有可枚举属性,不包含原型上的属性(不含Symbol属性)Object.keys(person1).forEach(key=>{ console.log(key,person1[key])})//sex man//age 24//job chengxuyuan//for..in.. 遍历包含对象自身及构造函数和原型上的所有可枚举属性(不含Symbol属性)for(let key in person1){ console.log(key,person1[key])}//sex man// age 24// job chengxuyuan// name xiaoming// sayName [Function]//Object.getOwnPropertyNames() 返回一个数组,包含对象自身及构造函数的所有属性(包括可枚举的和不可枚举的,不包含Symbbol属性),不包含原型上的属性Object.getOwnPropertyNames(person1).forEach(key=>{ console.log(key,person1[key])})// sex man// age 24// job chengxuyuan// height 185console.log(Object.getOwnPropertyNames(Person.prototype),'ad')//[ 'constructor', 'name', 'sayName' ] ad//person1.constructor 指向Peronconsole.log(person1.constructor) //[Function: Person]