javascript中floor使用方法總結
來源:懂視網
責編:小采
時間:2020-11-27 22:01:20
javascript中floor使用方法總結
javascript中floor使用方法總結:floor()方法的基本語法: Math.floor( x ) ; x表示數字,返回小于或等于數字x的最大整數。 我們下面來看具體的示例 代碼如下 <!DOCTYPE html> <html> <head> <title></title> </h
導讀javascript中floor使用方法總結:floor()方法的基本語法: Math.floor( x ) ; x表示數字,返回小于或等于數字x的最大整數。 我們下面來看具體的示例 代碼如下 <!DOCTYPE html> <html> <head> <title></title> </h
floor()方法的基本語法:
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>
瀏覽器上運行效果如下:所有數字的輸出都會小于或等于其最大整數。

聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
javascript中floor使用方法總結
javascript中floor使用方法總結:floor()方法的基本語法: Math.floor( x ) ; x表示數字,返回小于或等于數字x的最大整數。 我們下面來看具體的示例 代碼如下 <!DOCTYPE html> <html> <head> <title></title> </h