javascript - Check for NaN, null and >=0 in one condition -
i have var a;
its value can nan, null , +ve/-ve number including 0.
i require condition filters out values of such >=0 values yield true in if condition.
what best possible way achieve this, not wish use 3 different conditions joined using ||
typeof x == "number" && x >= 0 this works follows:
null--typeof null == "object"first part of expression returns falsenan--typeof nan == "number"nannot greater than, less or equal number including second part of expression returns falsenumber-- othernumbergreater or equal 0 expression returns true
Comments
Post a Comment