if something is defined javascript code example
Example 1: javascript check if variable exists
if (typeof myVar !== 'undefined') {
// myVar is defined
}
Example 2: How can I check whether a variable is defined in Node Js
if (query){
doStuff();
}