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
Post a Comment