D
D
Dilik Pulatov2019-03-05 10:51:50
JavaScript
Dilik Pulatov, 2019-03-05 10:51:50

How to correctly check variables for undefined?

5c7e2a44957f6852462994.jpeg
I don’t understand why this happens, but because of this, the server often crashes .......
how can I correctly check for undefined so that such an error does not occur?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MitakoHir, 2019-03-05
@dilikpulatov

You have an error that you are trying to read from res.name, but you have res itself undefined.
To check for undefined, just do this
if (res && (res.name && res.id))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question