JavaScript 中的 Math.floor() 函数
htmljavascriptweb developmentfront end technology更新于 2024/8/12 2:14:00
Math 对象的 floor() 函数接受浮点数并返回小于或等于给定数字的最大整数。如果给定数字本身是整数,此函数将返回相同的整数。
语法
其语法如下
Math.floor(160)
示例
<html> <head> <title>JavaScript 示例</title> </head> <body> <script type="text/javascript"> var result = Math.floor(160.98); document.write("Floor 值: "+result); </script> </body> </html>
输出
Floor 值: 160