方法一

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