xxxxxxxxxx
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
xxxxxxxxxx
"use strict";
// var someVar;
var declared;
try {
someVar;
declared = true;
} catch(e) {
declared = false;
}
if (declared) {
console.log("someVar is declared; now has the value: " + someVar);
} else {
console.log("someVar is not declared");
}