MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

SyntaxError: missing ] after element list

信息

SyntaxError: missing ] after element list

错误类型

SyntaxError.

哪里出错了?

数组初始化在某处出现了语法错误。比如缺少了右中括号("]") 或一个逗号 (",")。

示例

不正确的数组初始化

var list = [1, 2,

var instruments = [
  "Ukulele",
  "Guitar",
  "Piano"
};

var data = [{foo: "bar"} {bar: "foo"}];

正确的是:

var list = [1, 2];

var instruments = [
 "Ukulele",
 "Guitar",
 "Piano"
]; 

var data = [{foo: "bar"}, {bar: "foo"}];

相关

文档标签和贡献者

 此页面的贡献者: Ende93
 最后编辑者: Ende93,