我的 JavaScript 语法有什么问题?
我正在编写一个 javascript 幻灯片,但 Firebug 告诉我语法有错误或其他错误,但我就是看不出出了什么问题! 这是代码片段:
<script language="javascript" type="text/javascript">
var data = new Array();
var data[0] = new Array();
var data[0]['id'] = 'example';
var data[0]['height'] = 190;
</script>
Firebug 说:
missing ; before statement
var data[0] = new Array();
问题?好吧,我就是不明白问题出在哪里! 有人可以向我解释这个错误吗? 谢谢你!
I'm writing a javascript slideshow, but Firebug is telling me there's an error in the syntax, or something, but I just can't see what's wrong!
Here's the code snippet:
<script language="javascript" type="text/javascript">
var data = new Array();
var data[0] = new Array();
var data[0]['id'] = 'example';
var data[0]['height'] = 190;
</script>
Firebug says:
missing ; before statement
var data[0] = new Array();
The problem? Well, I just don't understand where the problem is!
Could anyone explain the mistake to me?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不能声明数组索引。除了第一行之外,丢失所有的
var
。You can't declare an array index. Lose the
var
on all but the first line.只保留第一个“var”语句,它将像这样工作:
看看 http://jsfiddle.net/cmTBc/
Keep only the first "var" statement, it will work like this:
Take a look http://jsfiddle.net/cmTBc/