javascript check if set code example
Example 1: javascript check if variable exists
if (typeof myVar !== 'undefined') {
// myVar is defined
}
Example 2: javascript check if set
if (typeof variable !== 'undefined') {
// the variable is defined
}
//or
if (typeof variable === 'undefined') {
// variable is undefined
}