What's the easiest way to check if a javascript variable is a number and greater than zero? -


this question has answer here:

i coded this:

        isnumbernotzero: function (num) {              // return false if num null, empty string or 0             if (num === null || typeof num === "undefined" || (typeof num === "string" && num.length === 0) || num == 0) {                 return false;             }             return true;         }, 

but there easier way this. code have not seem clean.

you doing lot of checking things not, when care if number greater zero.

just:

return typeof === "number" && > 0 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -