W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <p>请单击按钮将变量转换为数字。</p> <button onclick="myFunction()">试一试</button> <p id="demo"></p> <script> function myFunction() { var x1 = true; var x2 = false; var x3 = new Date(); var x4 = "999"; var x5 = "999 888"; var n = Number(x1) + "<br>" + Number(x2) + "<br>" + Number(x3) + "<br>" + Number(x4) + "<br>" + Number(x5); document.getElementById("demo").innerHTML = n; } </script> </body> </html>