Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. JavaScript
  3. Reference
  4. JavaScript error reference
  5. SyntaxError: missing ] after element list

SyntaxError: missing ] after element list

The JavaScript exception "missing ] after element list" occurs when there is an errorwith the array initializer syntax somewhere. Likely there is a closing square bracket(]) or a comma (,) missing.

Message

SyntaxError: missing ] after element list (Firefox)SyntaxError: Unexpected token ';'. Expected either a closing ']' or a ',' following an array element. (Safari)

Error type

SyntaxError.

What went wrong?

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

Examples

Incomplete array initializer

js
const list = [1, 2,const instruments = [  "Ukulele",  "Guitar",  "Piano",};const data = [{ foo: "bar" } { bar: "foo" }];

Correct would be:

js
const list = [1, 2];const instruments = ["Ukulele", "Guitar", "Piano"];const data = [{ foo: "bar" }, { bar: "foo" }];

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp