javascript string對象 Date對象 Math對象屬性和方法

來源:互聯網
上載者:User
 string對象 

string對象為操作字串的內容提供了很多方法. 

屬性 

length 字串的長度,即字串中字元的個數. 

方法 

big(),blink(),bold(),fixed(),italics(),small(),sub(),strike(),sup(),fontColor(color),fontSize(size) 

以上方法為字串增加相應的HTML標記. 
charAt(index) 返回字串中index處的字元. 
indexOf(searchValue,[fromIndex]) 該方法在字串中尋找第一次出現的searchValue.如果給定了fromIndex,則從字串內該位置開始搜尋,當searchValue找到後,返回該串第一個字元的位置. 
lastIndexOf(searchValue,[fromIndex]) 從字串的尾部向前搜尋searchValue,並報告找到的第一個執行個體. 
substring(indexA,indexB) 擷取自indexA到indexB的子串. 
toLowerCase(),toUpperCase() 將字串中所有字元全部轉換成大寫,小寫. 

Date對象 

要使用Date對象,必須先產生一個Date執行個體: 

變數名=new Date(); 

方法 

getDay(),getDate(),getHours(),getMinutes(),getMonth(),getSeconds(),getTime(), getTimeZoneOffset(),getYear() 

還有setDay... ... 

toGMTString() 用GMT格式返回目前時間. (Sun,12 Feb 1999 14:19:22 GMT) 
toLocaleString 用locale格式返回目前時間. (03/11/99 14:19:22) 
parse(date) 將普通date字串轉換成豪秒形式,從而給setTime()做參數. 

Math對象 

屬性 

LN10 (10的自然對數) 
PI (3.1415926...) 
SQRT1_2 (1/2的平方根) 

方法 

abs(x) 返回x的絕對值 
acos(x) 返回x的arc cosine值 
asin(x) 返回x的arc sin值 
atan(x) 返回x的arc tangent值 
ceil(x) 返回大於等於x的最小整數 
cos(x) 返回x的cosine值 
exp(x) 返回e的x次方 
floor(x) 返回小於等於x的最大整數 
log(x) 返回x的 
max(x,y) 返回x,y中的大值 
min(x,y) 返回x,y中的小值 
pow(x,y) 返回x的y次方 
round(x) 舍入到最近整數,(小於或等於0.5小數捨去) 
sin(x) 返回x的sin值 
sqrt(x) 返回x的平方根 
tan(x) 返回x的tangent值 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.