JavaScript Compruebe si existe una variable
if (typeof myVar !== 'undefined') {
// myVar is defined
}
Grepper
if (typeof myVar !== 'undefined') {
// myVar is defined
}
if (typeof(elem) !== 'undefined') {
if (elem != null) {