javascript中Math.floor的真正含义及用法?
1、打开开发工具(以HbuildX为例),并新建一个基本HTML项目Demo01

2、打开index.html文件并输入
<script type="text/javascript">
//Math
document.write(Math.floor(5.1))
document.write(Math.floor(5.2))
document.write(Math.floor(5.3))
document.write(Math.floor(5.4))
document.write(Math.floor(5.5))
document.write(Math.floor(5.6))
document.write(Math.floor(5.7))
document.write(Math.floor(5.8))
document.write(Math.floor(5.9))
</script>
注意:script标签是为了在html文件中引入JavaScript代码
之后我们预览查看效果,结果为555555555

3、在JavaScript中Math.floor() 方法执行的是向下取整的计算,它的返回值是最接近参数且不大于参数的整数。
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:172
阅读量:50
阅读量:187
阅读量:100
阅读量:191