JavaScript Sprawdź, czy istnieje zmienna
if (typeof myVar !== 'undefined') {
// myVar is defined
}
Grepper
if (typeof myVar !== 'undefined') {
// myVar is defined
}
if (typeof variable !== 'undefined') {
// the variable is defined
}
//or
if (typeof variable === 'undefined') {
// variable is undefined
}
if(element){
!isNaN(Number(element)) // check if variable is set and is a number
}
element && !isNaN(Number(element)) ? Number(element) : 0; // for number usage comming from db