亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

javaScript Array(數(shù)組)相關(guān)方法簡述

 更新時間:2009年07月25日 13:58:12   作者:  
javaScript Array(數(shù)組)相關(guān)方法簡述,讓大家更快的熟悉array數(shù)組的用法。
1.創(chuàng)建Array對象(賦初值情況下)兩種方法:
var aColor=new Array('red','black','yellow');
alert(aColor.toString());//output: red,black,yellow
var aColor=['red','black','blue'];
alert(aColor.toString());//output: red,black,blue
2.length:獲取數(shù)組長度
3.toString():輸出數(shù)組中的所有元素。
alert(aColor.toString());////output: red,black,yellow
4.valueOf():同3
5.join():連接數(shù)組值,將數(shù)組通過連接符連接,返回鏈接后的字符串
eg.alert(aColor.join("->"));//output:red->black->yellow
//(string)6.split():將字符串分割為字符數(shù)組,其中split(" ")將字符串分割為單個字符數(shù)組,eg."str"分割為s,t,r
7.contact():將參數(shù)附加到數(shù)組末尾,返回的函數(shù)值是新的Array對象
eg.
var aColor=new Array('red','black','yellow');
var aColorCon=aColor.concat("1","2");
alert(aColorCon.toString());//output: red,black,yellow,1,2
8.slice():返回具有指定項的新數(shù)組。
9.push()/pop():push()在數(shù)組結(jié)尾添加一個項,pop()刪除最后一個數(shù)組項并將該項值返回。
eg.
var aColor=new Array('red','black','yellow');
aColor.push("blue");
aColor.push("white");
alert(aColor.toString());
aColor.pop();
alert(aColor.toString());
10.shift():刪除數(shù)組中第一個項
11.unshift():向數(shù)組添加第一項,其他的各項后移。
var aColor=new Array('red','black','yellow');
aColor.shift();
alert(aColor.toString());
aColor.unshift("red");
alert(aColor.toString());
12.reverse():顛倒數(shù)組項的順序。
13.sort():對數(shù)組項升序排序。
eg.
var aColor=new Array('red','black','yellow');
aColor.sort();
alert(aColor);
alert(aColor.reverse());
14.splice().

相關(guān)文章

最新評論