NaN 的布尔值是 false
- <!DOCTYPE html>
- <html>
- <body>
- <p>显示 NaN 的布尔值:</p>
- <button onclick="myFunction()">试一试</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- var x = 10 / "H";
- document.getElementById("demo").innerHTML = Boolean(x);
- }
- </script>
- </body>
- </html>