Checking if a key exists in a JavaScript object?
Checking for undefined-ness is not an accurate way of testing whether a key exists. What if the key exists but the value is actually undefined? Expand snippet You should instead use the in operator: Expand snippet If you want to check if a key doesn’t exist, remember to use parenthesis: Expand snippet Or, if you … Read more