日期:2014-05-16  浏览次数:20466 次

也许是我白痴,为什么这句话怎么就会出现缺少“;”的错误呢?
我刚开始学习js,自己写的
var   anotherArray=new   Array{ "first   entry ", "second   entry ", "third   entry ", "forth   entry ", "fifth   entry "};
结果出现错误,提示:缺少“;”
复制别人的:
var   anotherArray   =   new   Array( "First   Entry ", "Second   Entry ", "Third   Entry ", "Fourth   Entry ", "Fifth   Entry ");
结果运行良好
我看不出除了大小写问题,其他没什么差别嘛,而且我的大小写都在引号内是字符串,为什么第一个就不行?
如果觉得是别的地方的错误,下面是全部的码:
<body>
<pre>
<script   language= "JavaScript ">
<!--
var   MyVariable= "Hello   there ";
var   thereplace=MyVariable.search( "there ");
document.writeln(thereplace);
var   NewMyVariable=MyVariable.replace( "there ", "Arman ");
document.writeln(NewMyVariable);
document.writeln( "origin: "+MyVariable);
document.writeln( "Big: "+MyVariable.big());
document.writeln( "Blink: "+MyVariable.blink());
document.writeln( "Fixed: "+MyVariable.fixed());
document.writeln( "FontColor:red_ "+MyVariable.fontcolor( "red "));
document.writeln( "FontSize:9pt_ "+MyVariable.fontsize( "9pt "));
document.writeln( "Italics: "+MyVariable.italics());
document.writeln( "Small: "+MyVariable.small());
document.writeln( "Sub: "+MyVariable.sub());
document.writeln( "Sup: "+MyVariable.sup());
document.writeln( "LowerCase: "+MyVariable.toLowerCase());
document.writeln( "UpperCase: "+MyVariable.toUpperCase());
document.writeln( "Multiple   formatting: "+MyVariable.toUpperCase().fontcolor( "green ").fontsize( "9pt ").bold().italics());
var   myarray=new   Array(5);
myarray[0]= "first   entry ";
myarray[1]= "second   entry ";
myarray[2]= "third   entry ";
myarray[3]= "forth   entry ";
myarray[4]= "fifth   entry ";
var   anotherArray   =   new   Array( "First   Entry ", "Second   Entry ", "Third   Entry ", "Fourth   Entry ", "Fifth   Entry ");
var   anotherArray=new   Array{ "first   entry ", "second   entry ", "third   entry ", "forth   entry ", "fifth   entry "};
//-->
</script>
</pre>
</body>

------解决方案--------------------
用小括号()不是大括号{}
var anotherArray=new Array( "first entry ", "second entry ", "third entry ", "forth entry ", "fifth entry ");
------解决方案--------------------
注意括号。。
是 new Array( ) 不是 new Array{ }
------解决方案--------------------
.....楼主的眼睛真是.......
该戴眼镜了。
------解决方案--------------------
对,楼上的正解,你声明一个数组。可以这样

var array = []; //空数组
var array1 = [ "first entry ", "second entry ", "third entry ", "forth entry ", "fifth entry "];