You want the typeof operator. Specifically:

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