W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>JavaScript 数学</h1> <p>Math.abs() 返回数的绝对值:</p> <p id="demo"></p> <script> let a = Math.abs(7.25); let b = Math.abs(-7.25); let c = Math.abs(null); let d = Math.abs("Hello"); let e = Math.abs(2-3); document.getElementById("demo").innerHTML = a + "<br>" + b + "<br>" + c + "<br>" + d + "<br>" + e; </script> </body> </html>