0
Q:

Javascript key exists

var person={"name":"Billy","age":20}
person.hasOwnProperty("name"); // true
person.hasOwnProperty("sex"); // false
6
if (obj.hasOwnProperty("key1")) {
  ...
}
4
"key" in obj // true, regardless of the actual value
0
var obj = { key: undefined };
obj["key"] !== undefined // false, but the key exists!
0

New to Communities?

Join the community