Prototype - abs() 方法
此方法返回数字的绝对值。
语法
number.abs();
返回值
返回数字的绝对值。
示例
<html> <head> <title>Prototype examples</title> <script type = "text/javascript" src = "/javascript/prototype.js"></script> <script> function showResult() { alert( "Math.abs(-5) : " + Math.abs(-5) ); alert( "(-5).abs() : " + (-5).abs() ); alert( "(5).abs() : " + (5).abs() ); } </script> </head> <body> <p>单击按钮查看结果。</p> <br /> <br /> <input type = "button" value = "Result" onclick = "showResult();"/> </body> </html>
输出
prototype_number_processing.html