內置對象

從手冊上總結下來的類型有:

Date,Math,Number,Boolean,String,Array,RegExp,Function,Object,全局,事件等。

1.Date 

屬性(1): 
constructor 所建立對象的函數參考 
prototype 能夠爲對象加入的屬性和方法 
方法(43): 
getDay() 返回一週中的第幾天(0-6) 
getYear() 返回年份.2000年以前爲2位,2000(包含)以後爲4位 
getFullYear() 返回完整的4位年份數 
getMonth() 返回月份數(0-11) 
getDate() 返回日(1-31) 
getHours() 返回小時數(0-23) 
getMinutes() 返回分鐘(0-59) 
getSeconds() 返回秒數(0-59) 
getMilliseconds() 返回毫秒(0-999) 
getUTCDay() 依據國際時間來得到現在是星期幾(0-6) 
getUTCFullYear() 依據國際時間來得到完整的年份 
getUTCMonth() 依據國際時間來得到月份(0-11) 
getUTCDate() 依據國際時間來得到日(1-31) 
getUTCHours() 依據國際時間來得到小時(0-23) 
getUTCMinutes() 依據國際時間來返回分鐘(0-59) 
getUTCSeconds() 依據國際時間來返回秒(0-59) 
getUTCMilliseconds()依據國際時間來返回毫秒(0-999) 
getTime() 返回從1970年1月1號0:0:0到現在一共花去的毫秒數 
getTimezoneoffset() 返回時區偏差值,即格林威治平均時間(GMT)與運行腳本的計算機所處時區設置之間相差的分鐘數) 
parse(dateString) 返回在Date字符串中自從1970年1月1日00:00:00以來的毫秒數 
setYear(yearInt) 設置年份.2位數或4位數 
setFullYear(yearInt)設置年份.4位數 
setMonth(monthInt) 設置月份(0-11) 
setDate(dateInt) 設置日(1-31) 
setHours(hourInt) 設置小時數(0-23) 
setMinutes(minInt) 設置分鐘數(0-59) 
setSeconds(secInt) 設置秒數(0-59) 
setMilliseconds(milliInt) 設置毫秒(0-999) 
setUTCFullYear(yearInt) 依據國際時間來設置年份 
setUTCMonth(monthInt) 依據國際時間來設置月(0-11) 
setUTCDate(dateInt) 依據國際時間來設置日(1-31) 
setUTCHours(hourInt) 依據國際時間來設置小時 
setUTCMinutes(minInt) 依據國際時間來設置分鐘 
setUTCSeconds(secInt) 依據國際時間來設置秒 
setUTCMilliseconds(milliInt)依據國際時間來設置毫秒 
setTime(timeInt) 設置從1970年1月1日開始的時間.毫秒數 
toGMTString() 根據格林威治時間將Date對象的日期(一個數值)轉變成一個GMT時間字符串,如:Weds,15 June l997 14:02:02 GMT 
toUTCString() 根據通用時間將一個Date對象的日期轉換爲一個字符串 
toLocaleString() 把Date對象的日期(一個數值)轉變成一個字符串,使用所在計算機上配置使用的特定日期格式 
toSource() 顯示對象的源代碼 
toString() 將日期對象轉換爲字符串 
UTC(yyyy, mm, dd, hh, mm, ss, msec)返回從格林威治標準時間到指定時間的差距,單位爲毫秒 
valueOf() 返回日期對象的原始值 
2.Math 
屬性: 
constructor 所建立對象的函數參考 
prototype 能夠爲對象加入的屬性和方法 
E 歐拉常量,自然對數的底(約等於2.718) 
LN2 2的自然對數(約等於0.693) 
LN10 10的自然對數(約等於2.302) 
LOG2E 以2爲底的e的對數.(約等於1.442) 
LOG10E 以10爲底的e的對數(約等於0.434) 
PI ∏的值(約等於3.14159) 
SQRT1_2 1/2(0.5)的平方根(即l除以2的平方根,約等於o.707) 
SQRT2 2的平方根(約等於1.414) 
方法: 
abs(x) 返回數字的絕對值 
acos(x) 返回數字的反餘弦值 
asin(x) 返回數字的反正弦值 
atan(x) 返回位於-PI/2 和 PI/2 的反正切值 
atan2(y,x) 返回(x,y)位於 -PI 到 PI 之間的角度 
ceil(x) 返回 x 四捨五入後的最大整數 
cos(x) 返回一個數字的餘弦值 
exp(x) 返回 E^x 值 
floor(x) 返回 x 四捨五入後的最小整數 
log(x) 返回底數爲E的自然對數 
max(x,y) 返回 x 和 y 之間較大的數 
min(x,y) 返回 x 和 y 之間較小的數 
pow(x,y) 返回 y^x 的值 
random() 返回位於 0 到 1 之間的隨機函數 
round(x) 四捨五入後取整 
sin(x) 返回數字的正弦值 
sqrt(x) 返回數字的平方根 
tan(x) 返回一個角度的正切值 
toSource() 顯示對象的源代碼 
valueOf() 返回數學對象的原始值 
3.Number 
屬性: 
MAX_VALUE The largest possible value a number in JavaScript can have 1.7976931348623157E+308 
MIN_VALUE The smallest possible value a number in JavaScript can have 5E-324 
NaN Equal to a value that is not a number. 
NEGATIVE_INFINITY A value that is less than MIN_VALUE. 
POSOTIVE_INFINITY A value that is greater than MAX_VALUE. 
prototype A static property of the Number object 
方法: 
toString Returns a string representing the specified object 
valueOf() 返回數學對象的原始值 
4.Boolean 
屬性: 
constructor 所建立對象的函數參考 
prototype 能夠爲對象加入的屬性和方法 
方法: 
toSource() 顯示對象的源代碼 
toString() 將布爾值轉換爲字符串,並且返回結果 
valueOf() 返回布爾對象的原始值 
5.String 
屬性: 
constructor 所建立對象的函數參考 
prototype 能夠爲對象加入的屬性和方法 
length 返回字符串的字符長度 
方法(20): 
anchor("name")用來把字符串轉換爲HTML錨點標記內(<A NAME=>) 
big() 把字符串中的文本變成大字體(<BIG>) 
blink() 把字符串中的文本變成閃爍字體(<BLINK>) 
bold() 把字符串中的文本變成黑字體(<B>) 
fixed() 把字符串中的文本變成固定間距字體,即電報形式(<TT>) 
fontcolor(color)設置字符串中文本的顏色(<FONT COLOR=>) 
Fontsize(size) 把字符串中的文本變成指定大小(<FONTSIZE=>) 
italics() 把字符串中的文本變成斜字體(<I>) 
Link(url)用來把字符串轉換-HTML鏈接標記中(<A HREF=>) 
small() 把字符串中的文本變成小字體(<SMALL>) 
strike() 把字符串中的文本變成劃掉字體(<STRIKE>) 
sub() 把字符串中的文本變成下標(subscript)字體((SUB>) 
sup() 把字符串中的文本變成上標(superscript)字體(<SUP>) 
charAt(index) 返回指定索引處的字符 
charCodeAt(index)返回一個整數,該整數表示String對象中指定位置處的字符的Unicode編碼 
concat(string2)連接兩條或多條字符串 
fromCharCode(num1, num2, …, numN)獲取指定的Unicode值並返回字符串 
indexOf(searchString, startIndex) 返回字符串中第一個出現指定字符串的位置 
lastlndexOf(searchString, startIndex) 返回字符串中最後一個出現指定字符串的位置 
match(regex) 在字符串中查找指定值 
replace(regex, newString)將字符串中的某些字符替換成其它字符 
search(regex) 針對某執行值對字符串進行查找 
slice(startIndex, endIndex)將部分字符抽出並在新的字符串中返回剩餘部分 
split(delimiter)將字符串分配爲數組 
substr(startIndex, length) 從startIndex取,取length個字符 
substring(startIndex, endIndex) 從startIndex和endIndex之間的字符,不包括endIndex 
toLowerCase() 把字符串中的文本變成小寫 
toUpperCase() 把字符串中的文本變成大寫 
toSource() 顯示對象的源代碼 
valueOf() 返回字符串對象的原始值 
6.Array 
屬性: 
constructor 所建立對象的函數參考 
prototype 能夠爲對象加入的屬性和方法 
index For an array created by a regular expression match, the zero-based index of the match in the string. 
input For an array created by a regular expression match, reflects the original string against which the regular expression was matched. 
length 獲取數組元素的個數,即最大下標加1 
方法(13): 
concat(array1,arrayn)將兩個或兩個以上的數組值連接起來,合併後返回結果 
join(string) 將數組中元素合併爲字符串,string爲分隔符.如省略參數則直接合並,不再分隔 
pop() 移除數組中的最後一個元素並返回該元素 
push(value) 在數組的末尾加上一個或多個元素,並且返回新的數組長度值 
reverse() 顛倒數組中元素的順序,反向排列 
shift() 移除數組中的第一個元素並返回該元素 
slice(start, deleteCount, [item1[, item2[,...[,itemN]]]]) 返從一個數組中移除一個或多個元素,如果必要,在所移除元素的位置上插入新元素,返回所移除的元素 
sort(compare Function) 在未指定排序號的情況下,按照元素的字母順序排列,如果不是字符串類型則轉換成字符串再排序,返回排序後的數組 
splice() 爲數組刪除並添加新的元素 
toSource() 顯示對象的源代碼 
toString() 將數組所有元素返回一個字符串,其間用逗號分隔 
unshift(value)爲數組的開始部分加上一個或多個元素,並且返回該數組的新長度 
valueOf() 返回數組對象的原始值 
7.RegExp 
屬性: 
$1, ..., $9 Parenthesized substring matches, if any. 
$_ See input. 
$* See multiline. 
$& See lastMatch. 
$+ See lastParen. 
$` See leftContext. 
$' See rightContext. 
global Whether or not to test the regular expression against all possible matches in a string, or only against the first. 
ignoreCase Whether or not to ignore case while attempting a match in a string. 
input The string against which a regular expression is matched. 
lastIndex The index at which to start the next match. 
lastMatch The last matched characters. 
lastParen The last parenthesized substring match, if any. 
leftContext The substring preceding the most recent match. 
multiline Whether or not to search in strings across multiple lines. 
rightContext The substring following the most recent match. 
source The text of the pattern. 
方法: 
compile Compiles a regular expression object. 
exec Executes a search for a match in its string parameter. 
test Tests for a match in its string parameter 
8.Function 
屬性: 
arguments An array corresponding to the arguments passed to a function. 
arity Indicates the number of arguments expected by the function. 
caller Specifies which function called the current function. 
prototype Allows the addition of properties to a Function object. 
方法: 
toString Returns a string representing the specified object. 
9.Object 
屬性: 
constructor Specifies the function that creates an object's prototype. 
prototype Allows the addition of properties to all objects. 
方法: 
eval Evaluates a string of JavaScript code in the context of the specified object. 
toString Returns a string representing the specified object. 
unwatch Removes a watchpoint from a 屬性源 the object. 
valueOf Returns the primitive value of the specified object. 
watch Adds a watchpoint to a 屬性源 the object. 
10.全局 
屬性: 
Infinity 指定一個正負無窮大的數值 
NaN 指定一個 “非數字” 值 
undefined 指定一個未被賦值的變量 
方法: 
decodeURI() 爲加密的URI進行解碼 
decodeURIComponent() 爲加密的URI組件解碼 
encodeURI() 將字符串加密爲URI 
encodeURIComponent() 將字符串加密爲URI組件 
escape(string) 加密一個字符串 
unescape() 使用escape()對一個字符串進行解碼 
eval(string) 判斷一個字符串並將其以腳本代碼的形式執行 
isFinite(number) 檢測一個值是否爲一個有限數字,返回True或False 
isNaN(string) 檢測一個值是否不是一個有限數字 
Number() 將一個對象的值轉換爲一個數字 
parseFloat(string) 將一個字符串解析爲一個浮點數字 
parseInt(string) 將一個字符串解析爲一個整數,不是四捨五入操作,而是切尾 
String(object) 將一個對象值轉換爲一個字符串 
number(object) 
11.事件 
屬性: 
a.窗口事件,只在body和frameset元素中才有效 
onload 頁面或圖片加載完成時 
onunload 用戶離開頁面時 
b.表單元素事件,在表單元素中才有效 
onchange 框內容改變時 
onsubmit 點擊提交按鈕時 
onreset 重新點擊鼠標按鍵時 
onselect 文本被選擇時 
onblur 元素失去焦點時 
onfocus 當元素獲取焦點時 
c.鍵盤事件,在base,bdo,br,frame,frameset,head,html,iframe,meta,param,script,style,title元素裏都無效 
onkeydown 按下鍵盤按鍵時 
onkeypress 按下或按住鍵盤按鍵時 
onkeyup 放開鍵盤按鍵時 
d.在base,bdo,br,frame,frameset,head,html,iframe,meta,param,script,style,title元素裏都無效 
onclick 鼠標點擊一個對象時 
ondblclick 鼠標雙擊一個對象時 
onmousedown 鼠標被按下時 
onmousemove 鼠標被移動時 
onmouseout 鼠標離開元素時 
onmouseover 鼠標經過元素時 
onmouseup 釋放鼠標按鍵時 
e.其他 
onresize 當窗口或框架被重新定義尺寸時 
onabort 圖片下載被打斷時 
onerror 當加載文檔或圖片時發生錯誤時 
自定義對象:有初始化對象和定義構造函數的對象兩種方法 
a:初始化對象 
例如: 對象={屬性1:值1;屬性2:值2;......屬性n:值n} 注意:每個屬性/值對之間用分號隔開; 
b: 定義構造函數的對象 
例如: 
function 函數名(屬性1, 屬性2,......屬性N){ 
this.屬性1=屬性值1; 
this.屬性2=屬性值2; 
this.屬性n=屬性值n; 
this.方法名1=函數名1; 
this.方法名2=函數名2; 
發佈了45 篇原創文章 · 獲贊 24 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章