yuanquan001 发表于 2007-11-14 16:01

大家看看是咋回事

为什么输出了undefined 而不是输出 10 20 30

yuanquan001 发表于 2007-11-14 16:02

<P>就是着段代码<BR>&lt;script language="javascript"&gt;<BR>var x=new Array(1,2,3);<BR>var y=5;<BR>document.write("调用函数前:&lt;br&gt;");<BR>document.write("基本类型变量的值为",y,"&lt;br&gt;");<BR>document.write("引用类型数组的值为:");<BR>for(i=0;i&lt;x.length;i++)<BR>document.write(x[i]," ");<BR>document.write("&lt;br&gt;");</P>
<P>example(x,y);</P>
<P>document.write("调用函数后:&lt;br&gt;");<BR>document.write("基本类型变量的值为:",y,"&lt;br&gt;");<BR>document.write("引用类型数组的值为:");<BR>  for(i=0;i&lt;x.length;i++);<BR>    document.write(x[i]," ");</P>
<P>function example(a,b)<BR>{<BR>a[0]=10;<BR>a[1]=20;<BR>a[2]=30;<BR>b=50;<BR>document.write("函数中:&lt;br&gt;");<BR>document.write("基本类型变量的值为:",b," ");<BR>document.write("引用类型数组的值为:");<BR>   for(i=0;i&lt;a.length;i++)<BR>     document.write(a[i]," ");<BR>     document.write("&lt;br&gt;");</P>
<P>}</P>
<P>&lt;/script&gt;</P>
<P>调用函数前:<BR>基本类型变量的值为5<BR>引用类型数组的值为:1 2 3 <BR>函数中:<BR>基本类型变量的值为:50 引用类型数组的值为:10 20 30 <BR>调用函数后:<BR>基本类型变量的值为:5<BR>引用类型数组的值为:undefined </P>
<P>咋输出了undefined 而不是输出10 20 30呢? 大哥,帮帮忙啊<BR></P>

hwoarangzk 发表于 2007-11-14 16:04

<P>去看你发的另一个帖子吧</P>

yuanquan001 发表于 2007-11-14 16:11

太感谢了真是

xueze 发表于 2007-11-16 13:21

都是分号惹的祸~~高手就是细心呀~~~看来想成为一个高手必须得有扎实的基本功才行~~~

页: [1]

编程论坛