isNaN-2

 

In this example, We will see isNaN with blank value. In JavaScript, isNaN("") will return false because JavaScript treat blank string as 0(zero) and "" == 0 will return true. so that is why IsNaN("") will return false.

 
 
 
<!DOCTYPE html> <html> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <p>The isNaN() function returns true if the value is NaN (Not-a-Number), and false if not.</p> <button onclick="checkNumber()">Check the value</button> <p id="sample"></p> <script> function checkNumber() { var a = isNaN("37") + "<br>"; var b = isNaN("37.37") + "<br>"; var c = isNaN("") + "<br>"; var d = isNaN(" ") + "<br>"; numbers=a+b+c+d; document.getElementById("sample").innerHTML = numbers; } </script> </body> </html>
Output