获取对象的所有属性名,返回一个数组
let obj = { name:'fujinting',age:21} Object.getOwnPropertyNames(obj)
或
let obj = { name:'fujinting',age:21} Object.keys(obj)
检查对象上是否存在某个属性,返回true或false
let obj = { name:'fujinting',age:21} hasOwnProperty("name")
直接遍历对象的属性
let obj = { name:'fujinting',age:21} for(let v in obj) { console.log(v) }