js- 判断属性是否 属于该对象 hasOwnproperty()

 

var obj ={
name:'suan',
sex :'male',
age:150,
height:185,
characeter:true,
_proto_:{
lastName:'susan',
_proto:{
lastSex:'male'
}
}
}
for(var key in obj){
if (obj.hasOwnProperty(key)){
console.log(obj[key])
}
}

猜你喜欢

转载自www.cnblogs.com/jie-xuan/p/11311333.html