isNaN

isNaN(x)

Try it yourself:


isNaN(): detect invalid numeric results

isNaN(x) tests whether x is the special “not a number” value. NaN often results from undefined arithmetic, failed conversion, or invalid numerical input.

Use it as a guard

Check a result before continuing a calculation or rendering a chart. NaN tends to propagate through arithmetic, so early detection is clearer than debugging a later sum() or mean().

Related tests

isFinite() also rejects infinities. isNumeric() checks whether a value is numeric in the first place, and isInteger() narrows the accepted domain further. Use isZero() before division where zero is the issue.

Do not compare directly

NaN is not reliably identified with ordinary equality. Use this predicate rather than comparing a value to NaN.

Try Is Na N in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions