1myObj.hasOwnProperty('key') // it checks object for particular key and not on prototype
1"key" in obj // true, regardless of the actual value
2
3If you want to check if a key doesn't exist, remember to use parenthesis:
4!("key" in obj) // true if "key" doesn't exist in object
5!"key" in obj // ERROR! Equivalent to "false in obj"
6
7Or, if you want to particularly test for properties of the object instance (and not inherited properties), use hasOwnProperty:
8obj.hasOwnProperty("key") // true