javascript check if variable is "" code example
Example 1: javascript check if variable exists
if (typeof myVar !== 'undefined') {
// myVar is defined
}
Example 2: How can I test whether a variable has a value in JavaScript?
if (typeof variable == "undefined") {...} --> return true if variable undefined
//An empty string evaluates to FALSE in JavaScript so you can just do:
if (variable) {...}