GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

SyntaxError: missing ] after element list

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

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

## Message

```plain
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 a
closing square bracket (`]`) or a comma (`,`) missing.

## Examples

### Incomplete array initializer

```js-nolint example-bad
const list = [1, 2,

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

const data = [{ foo: "bar" } { bar: "foo" }];
```

Correct would be:

```js example-good
const list = [1, 2];

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

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

## See also

- Array

source: MDN Web Docs mirror · page

Cite this

"SyntaxError: missing ] after element list". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_bracket_after_list

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·