Javascript中数组

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>JavaScript数组</title>
</head>
   
 <body>
 <script>
 var number=new Array(3);
 number[0]="中";
 number[1]="国";
 number[2]="人";
 for(var i=0;i<3;i++)
    document.write(number[i]);
    document.write("<br/>")
 document.write("共有"+ number.length + "个元素" + "<br/>")
 </script>
 <script>
 
 
 var num1=new Array("a","b","c")
 var num2=new Array("1","2","3")
 document.write(num1 + "<br/>")
 document.write(num1.join("-"))
 document.write("<br/>")
 document.write(num2 +"<br/>")
 document.write(num1.concat(num2))
 document.write("<br/>")
 num1.push("A","B")
 document.write(num1)
 document.write("<br/>")
 num1.pop()
 document.write(num1)
 document.write("<br/>")
 num1.shift("中","国")
 document.write(num1)
 document.write("<br/>")
    num1.unshift("中","国")
 document.write(num1)
 </script>
 
 
 </body>
 
</html>

    A+
发布日期:2010年03月07日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: