0 Members and 1 Guest are viewing this topic.
var obj = { key: undefined };obj["key"] != undefined // false, but the key exists!
"key" in obj // true, regardless of the actual value
!("key" in obj) // true if "key" doesn't exist in object!"key" in obj // ERROR! Equivalent to "false in obj"
obj.hasOwnProperty("key") // true
var aa = {hello: "world"};alert( aa["hello"] ); // popup box with "world"alert( aa["goodbye"] ); // popup boc with "undefined"// note the three equal signs so that null won't be equal to undefinedif( aa["goodbye"] === undefined ) { // do something}// this works even if you have {"goodbye": undefined}if( "goodbye" in aa ) { // do something}