JavaScript isNaN() function

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('w3spoint') + ": 'w3spoint'<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:

Please follow and like us:
Content Protection by DMCA.com