判断一个对象中是否有指定属性

判断一个对象中是否有指定属性

1 hasOwnProperty

var a  = {b:1}
a.hasOwnProperty('b')
true
a.hasOwnProperty('c')
false

  2 in

 

原链接: https://www.cnblogs.com/guozongzhang/p/10823806.html

 

 

posted @ 2019-05-21 18:35  星星糖  阅读(5088)  评论(0编辑  收藏  举报