java script 基本函數

來源:互聯網
上載者:User

標籤:abs   擷取   cond   time   目前時間   rip   系統   注意   gets   

Math.random()    是令系統隨機選取大於等於 0.0 且小於 1.0 的偽隨機 double 值。

日期時間函數(需要用變數調用):
var b = new Date();      //擷取目前時間
b.getTime() ;                  //擷取時間戳記
b.getFullYear();             //擷取年份
b.getMonth()+1;          //擷取月份要+11
b.getDate();                  //擷取天
b.getHours();               //擷取小時
b.getMinutes() ;          //擷取分鐘
b.getSeconds() ;          //擷取秒數
b.getDay()  ;               //擷取星期幾
b.getMilliseconds();      //擷取毫秒
Date()   ;                     //擷取完整日期

數學函數(用Math來調用):
abs(x)    返回數的絕對值。
ceil(x)    對數進行上舍入。
floor(x)    對數進行下舍入。
round(x)    把數四捨五入為最接近的整數。
max(x,y)    返回 x 和 y 中的最高值。
min(x,y)    返回 x 和 y 中的最低值。
pow(x,y)    返回 x 的 y 次冪。
sqrt(x)    返回數的平方根。

var n=Math.sprt(4)   //給四開平方根,注意Math 的大小寫;

java script 基本函數

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.