SyntaxError: missing ] after element list

由於本文件沒有此語言的翻譯版本,您閱讀的是英文版的內容。 幫助我們翻譯這篇文章!

Message

SyntaxError: missing ] after element list

Error type

SyntaxError.

What went wrong?

There is an error with the array initializer syntax somewhere. Likely there is a closing bracket ("]") or a comma (",") missing.

Examples

Incomplete array initializer

var list = [1, 2,

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

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

Correct would be:

var list = [1, 2];

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

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

See also