A
A
artshelom2016-07-18 02:19:35
Node.js
artshelom, 2016-07-18 02:19:35

How to check the existence of an object?

Hello, how can I check for the existence of an object ??
I tried this code, it does not check for the existence of
if(Lister==undefined)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2016-07-18
@bingo347

if(typeof Lister === 'undefined') {
  // не существует
} else {
  // cуществует
}

if only the "exists" case is needed, then:
if(typeof Lister !== 'undefined') {
  // существует
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question