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知識點的全部內容,感謝大家對武林網的支持。
新聞熱點
疑難解答