The isNan() function returns true if the variable value is not a number otherwise returns false. It internally checks whether the specified value is an illegal number or not.
Syntax:
isNaN(value)
Parameters:
value: It represents the value to be checked for not a number.
Returns:
It returns true if the value is an illegal number otherwise returns false.
Example:
<!DOCTYPE html> <html> <body> <script> function testNaN() { var result = ""; result = result + isNaN(45) + ": 45<br>"; result = result + isNaN(-5.2) + ": -5.2<br>"; result = result + isNaN(25-12) + ": 5-2<br>"; result = result + isNaN(0) + ": 0<br>"; result = result + isNaN('23') + ": '123'<br>"; result = result + isNaN('w3schools') + ": 'w3schools'<br>"; result = result + isNaN('2019/05/12') + ": '2019/05/12'<br>"; result = result + isNaN('') + ": ''<br>"; result = result + isNaN(true) + ": true<br>"; result = result + isNaN(undefined) + ": undefined<br>"; result = result + isNaN('NaN') + ": 'NaN'<br>"; result = result + isNaN(NaN) + ": NaN<br>"; result = result + isNaN(0 / 0) + ": 0 / 0<br>"; document.write(result); } testNaN(); </script> </body> </html>
Related topics:
- What is JavaScript?
- JavaScript advantages and disadvantages
- Javascript External file
- Javascript isNaN()
- Javascript Undefined and Null
- Javascript Create object
- JavaScript access cookie
- Javascript read cookie
- Javascript get cookie by name
- Javascript detete cookie
- Javascript redirect URL
- Javascript print webpage
- Javascript exceptions