1 Math.random()方法
????功能: 返回0-1之間的隨機(jī)數(shù)
for(var?i=0;i<5;i++){ console.log(Math.random()); }
2 Math.ceil(x)方法
????功能: 對(duì)數(shù)字x向上取整
????注意: 如果x是正數(shù)? 向上取 如果是負(fù)數(shù) 可以直接理解為不要小數(shù)的部分(也是向上取整)
//?如果是正數(shù) console.log(Math.ceil(2.4));??//?3 console.log(Math.ceil(2.8));??//?3 //?如果是負(fù)數(shù) console.log(Math.ceil(-1.4));?//?-1 console.log(Math.ceil(-1.8));??//?-1
3 Math.floor(x)方法
????功能: 對(duì)數(shù)字x向下取整
console.log(Math.floor(2.4));??//?2? console.log(Math.floor(2.8));?//??2 //?如果是負(fù)數(shù) console.log(Math.floor(-1.4));???//?-2 console.log(Math.floor(-1.8));??//??-2
4 Math.round(x)方法
功能: 對(duì)數(shù)字x四舍五入取整(注意最后還是一個(gè)整數(shù))
console.log(Math.round(2.4));??//?2 console.log(Math.round(2.8));???//?3 //?如果是負(fù)數(shù) console.log(Math.round(-1.4));???//?-1 console.log(Math.round(-1.8));???//?-2
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。