当前位置: 移动技术网 > IT编程>开发语言>JavaScript > javascript中floor使用方法总结

javascript中floor使用方法总结

2019年05月29日  | 移动技术网IT编程  | 我要评论

floor()方法的基本语法

math.floor( x ) ;

x表示数字,返回小于或等于数字x的最大整数。

我们下面来看具体的示例

代码如下

<!doctype html>
<html>
 <head>
  <title></title>
 </head>
 <body> 
<script type="text/javascript"> 
 document.write(math.floor(-2)+"<br/>"); 
 document.write(math.floor(-2.56)+"<br/>"); 
 document.write(math.floor(2.56)+"<br/>"); 
  document.write(math.floor(7.2+9.3));  
</script> 
 </body>
</html>

浏览器上运行效果如下:所有数字的输出都会小于或等于其最大整数。

以上就是本篇关于floor知识点的全部内容,感谢大家对移动技术网的支持。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网