I have a var a;
Its value can be NaN, null and any +ve/-ve number including 0.
I require a condition which filters out all the values of a such that
typeof x == "number" && x >= 0
This works as follows:
null
-- typeof null == "object"
so first part of expression returns falseNaN
-- typeof NaN == "number"
but NaN
is not greater than, less than or equal to any number including itself so second part of expression returns falsenumber
-- any other number
greater than or equal to zero the expression returns true