執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Number Methods</h1> <h2>The parseFloat() Method</h2> <p>Parse a string and returns the first number:</p> <p id="demo"></p> <script> document.getElementById("demo").innerHTML = Number.parseFloat("40.00") + "<br>" + Number.parseFloat(" 40 ") + "<br>" + Number.parseFloat("40 years") + "<br>" + Number.parseFloat("40H") + "<br>" + Number.parseFloat("H40"); </script> </body> </html>