I want to find out whether an element in some multidimensional array x
is undefined, for example:
typeof x[i][j][k] === 'undefined'
The problem is that if for example x[i][j]
is undefined I get an error. To be on the safe side I would have to instead check:
typeof x === 'undefined'
|| typeof x[i] === 'undefined'
|| typeof x[i][j] === 'undefined'
|| typeof x[i][j][k] === 'undefined'
But is there an easier way in JavaScript to check whether x[i][j][k]
is undefined?