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

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