遍历
属性遍历:
1、for...in:包含原型属性
1)[[Enumberable]] = true
1)Object.hasOwnProperty() 筛出原型属性
2、Object.keys(obj);
var obj = { name:'aa', age: 22 } var s = Object.keys(obj); console.log(s); // ["name", "age"]
3、Object.getOwnPropertyName(obj) 遍历所有可枚举不能枚举的属性
var person = { name:'xa', age:34, sex:'nv' } Object.defineProperty(person,"name",{ enumerable:false }) console.log(Object.getOwnPropertyNames(person)) // ["name", "age", "sex"]