JavaScript check if variable exists (is defined/initialized)

PHOTO EMBED

Thu Jun 24 2021 13:41:02 GMT+0000 (Coordinated Universal Time)

Saved by @roberth #javascript

if (typeof variable !== 'undefined') {
    // the variable is defined
}
content_copyCOPY

https://stackoverflow.com/questions/5113374/javascript-check-if-variable-exists-is-defined-initialized