با این کد میتونید بررسی کنید که آیا یک متغیر تعریف شده یا خیر.

/** helper to determine if a variable is defined
     */
    function isDefined(foo) {
    return 'undefined' !== typeof(foo) && null != foo;
    }