if a variable is undefined javascript code example
Example 1: javascript check for undefined
if (typeof myVariable === 'undefined'){
//myVariable is undefined
}
Example 2: nodejs check if variable is undefined
if ( typeof query !== 'undefined' && query )
{
//do stuff if query is defined and not null
}
else
{
}