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