W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <p>单击按钮可解析不同的字符串。</p> <button onclick="myFunction()">试一试</button> <p id="demo"></p> <script> function myFunction() { var a = parseFloat("10") var b = parseFloat("10.00") var c = parseFloat("10.33") var d = parseFloat("34 45 66") var e = parseFloat(" 60 ") var f = parseFloat("40 years") var g = parseFloat("He was 40") document.getElementById("demo").innerHTML = a + "<br>" + b + "<br>" + c + "<br>" + d + "<br>" + e + "<br>" + f + "<br>" + g; } </script> </body> </html>