JavaScript isNaN() Function
The isNaN() function is used to check whether a given value is an illegal number or not. It returns true if value is a NaN else returns false. It is different from the Number.isNaN() Method.
Syntax:
isNaN( value )
Parameter Values: This method accepts single parameter as mentioned above and described below:
- value: It is a required value passed in the isNaN() function.
Return Value: It returns a Boolean value i.e. returns true if the value is NaN else returns false.
Javascript
<script> document.write(isNaN(12) + "<br>" ); document.write(isNaN(0 / 0) + "<br>" ); document.write(isNaN(12.3) + "<br>" ); document.write(isNaN( "Geeks" ) + "<br>" ); document.write(isNaN( "13/12/2020" ) + "<br>" ); document.write(isNaN(-46) + "<br>" ); document.write(isNaN(NaN) + "<br>" ); </script> |
Output:
false true false true true false true
Supported Browsers:
- Chrome 1 and above
- Firefox 1 and above
- Edge 12 and above
- Opera 3 and above
- Safari 1 and above