-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
57 lines (38 loc) · 1.15 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
title: "SyntaxError: missing ] after element list"
slug: Web/JavaScript/Reference/Errors/Missing_bracket_after_list
page-type: javascript-error
---
{{jsSidebar("Errors")}}
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
{{jsxref("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
- {{jsxref("Array")}}