Non-numeric parameter for Number()


#1

When I pass a non-numeric argument to Number() (eg. Number(“X”)), it returns NaN. Is there any way of checking for this. Neither If Number(“X”) = “NaN” or If Number(“X”) = NaN seem to work. Basically I want a way to check if something is numeric.


#2

Never mind - I just found the isNumeric function


#3

Just as an FYI ‘typeof’ is good for checking types BUT NaN is not a reserved word or type. However you can check if a variable is of a specific type or “undefined”