W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> var b1 = Boolean(100); var b2 = Boolean(3.14); var b3 = Boolean(-15); var b4 = Boolean("Hello"); var b5 = Boolean('false'); var b6 = Boolean(1 + 7 + 3.14); document.getElementById("demo").innerHTML = "100 是 " + b1 + "<br>" + "3.14 是 " + b2 + "<br>" + "-15 是 " + b3 + "<br>" + "任何(非空)字符串是 " + b4 + "<br>" + "即使字符串 'false' 也是 " + b5 + "<br>" + "任何表达式(除了零)是 " + b6; </script> </body> </html>