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值