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?
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?
If you are using underscore.js library then object/array operations become simple.
In your case _.has method can be used. Example:
returns true
But,
returns false