源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>享学课堂</title> </head> <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 is " + b1 + "<br>" + "3.14 is " + b2 + "<br>" + "-15 is " + b3 + "<br>" + "任意(非空)字符串是 " + b4 + "<br>" + "'false' 字符串是 " + b5 + "<br>" + "任意表达式 (非零)是 " + b6; </script> </body> </html>
运行结果