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?<
hasOwnProperty.call(obj, key);
The underscore.js way -
if(_.has(this.options, 'login')){ //key 'login' exists in this.options } _.has = function(obj, key) { return hasOwnProperty.call(obj, key); };