How do I check if a particular key exists in a JavaScript object or array?
If a key doesn\'t exist, and I try to access it, will it return false? Or throw an error?<
The easiest way to check is
"key" in object
for example:
var obj = { a: 1, b: 2, } "a" in obj // true "c" in obj // false
Return value as true implies that key exists in the object.