JS 判别JSON.Object是否存在

方法一

var obj = { key: undefined }; 
obj["key"] != undefined // false, but the key exists! 

You should instead use the in operator: 

"key" in obj // true, regardless of the actual value 

2.

查看Key是否存在

!("key" in obj) // true if "key" doesn't exist in object 
!"key" in obj // ERROR! Equivalent to "false in obj" 

 

3.
obj.hasOwnProperty("key") // true

posted @ 2018-08-25 13:26  JokerJason  阅读(2488)  评论(0)    收藏  举报

It's not who you are underneath, it's what you do that defines you

Brick walls are there for a reason :they let us prove how badly we want things