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