javascript check if var is undefined empty or null code example
Example 1: javascript check if undefined or null
if( typeof myVar === 'undefined' || myVar === null ){
// myVar is undefined or null
}
Example 2: javascript check if variable is empty
if( value ) {
//
}
/**
* This will evaluate to true if value is not:
* null
* undefined
* NaN
* empty string ("")
* 0
* false
*/