This keyExists(key, search)
can be used to easily lookup a key within objects or arrays!
Just pass it the key you want to find, and search obj (the object or array) you want to find it in.
function keyExists(key, search) {_x000D_
if (!search || (search.constructor !== Array && search.constructor !== Object)) {_x000D_
return false;_x000D_
}_x000D_
for (var i = 0; i < search.length; i++) {_x000D_
if (search[i] === key) {_x000D_
return true;_x000D_
}_x000D_
}_x000D_
return key in search;_x000D_
}_x000D_
_x000D_
// How to use it:_x000D_
// Searching for keys in Arrays_x000D_
console.log(keyExists('apple', ['apple', 'banana', 'orange'])); // true_x000D_
console.log(keyExists('fruit', ['apple', 'banana', 'orange'])); // false_x000D_
_x000D_
// Searching for keys in Objects_x000D_
console.log(keyExists('age', {'name': 'Bill', 'age': 29 })); // true_x000D_
console.log(keyExists('title', {'name': 'Jason', 'age': 29 })); // false
_x000D_
It's been pretty reliable and works well cross-browser.