You cannot achieve this with native JavaScript. But there are many different ways to easily achieve this. Here's one:
var isset = function isset (arr) {
var indexes = Array.prototype.slice.call(arguments, 1);
var current = arr;
for (var i = 0; i < indexes.length; i += 1) {
arr = arr[indexes[i]];
if (typeof arr === 'undefined') {
return false;
}
}
return true;
}
Then you can use it like this:
var arr = [1, [11, 22, [[1111, 2222, 4444], 222, 333]], 3];
console.log(isset(arr, 0, 1)); // -> false
console.log(isset(arr, 0, 4, 4, 6, 7, 8)); // -> false
console.log(isset(arr, 1, 2, 0)); // -> true
if (isset(arr, 1, 2, 4)) {
// ...
}