You are on the editable version of MDN Web Docs

View as an MDN Web Docs user: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_bracket_after_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 bracket ("]") or a comma (",") missing.

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

Document Tags and Contributors

Contributors to this page: fscholz, mdnwebdocs-bot, nmve
Last updated by: fscholz,