JSP(数组)(2)
}
var arr2=new MyArray2(2);
arr[0]=3;
arr[1]="ba";
arr[2]=4;
var x,str="";
for(x in arr)
{
str += x + ":" + arr[x]+"\n";
}
alert(str);
</script>
</html>
[html]
<html>
<script language="javascript">
function MyArray()
{
this.length=arguments.length;
for(var i;i < this.length;i++)
{
this[i]=arguments[i];
}
}
var str="";
var arr=new MyArray(4,3.5,"abo");
for(var i = 0;i < arr.length;i++)
{
str +=arr[i] + "\n";
}
alert(str);
function MyArray2(size)
{
this.length=size;
for(var i=0;i<size;i++)
{
this[i]="";
}
}
var arr2=new MyArray2(2);
arr[0]=3;
arr[1]="ba";
arr[2]=4;
var x,str="";
for(x in arr)
{
str += x + ":" + arr[x]+"\n";
}
alert(str);
</script>
</html>
3,Array对象
* Array()
[html]
<html>
<script language="javascript">
var arr = new Array();
arr[0]='1';
arr[1]=2;
alert(arr.length);
</script>
</html>
相关新闻>>
- 发表评论
-
- 最新评论 更多>>