How can I check whether a variable is defined in Node.js?


Question

I am working on a program in node.js which is actually js.

I have a variable :

var query = azure.TableQuery...

looks this line of the code is not executing some times.

my question is :

How can I do a condition like:

if this variable is defined do this.
else do this.

I cannot do in js (query!= null)

I want to see if this variable is defined do some thing. how to do this

1
60
1/10/2018 7:33:31 PM

if ( typeof query !== 'undefined' && query )
{
  //do stuff if query is defined and not null
}
else
{

}
83
11/11/2012 9:58:07 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon