B
B
Bla Bla2021-01-09 20:26:42
Node.js
Bla Bla, 2021-01-09 20:26:42

How to check an element in an array for 'undefined'?

I understand the question is funny, but when I check an element in an array for "undefined": I get an error something like "Cannot read property '-1' of undefined" when j = i = -1. That's how I can check the existence of an index in an array. if (typeof array[j][i] == 'undefined')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Ezhgurov, 2021-01-09
@SubUser

if (j in array && i in array[j])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question