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