Skip to content
JS
JavaScript error

SyntaxError

The JavaScript exception "a declaration in the head of a for-of loop can't have an initializer" occurs when the head of a for...of loop contains an initializer expression such as for (const i = 0 of iterable). This is not allowed in for-of loops.

Reference entryJavaScriptFetched
SyntaxError: for-of loop variable declaration may not have an initializer. (V8-based)
As listed by MDN Web Docs
SyntaxError: a declaration in the head of a for-of loop can't have an initializer (Firefox)
As listed by MDN Web Docs
SyntaxError: Cannot assign to the loop variable inside a for-of loop header. (Safari)
As listed by MDN Web Docs
Category
SyntaxError
Severity
error
Runtime
both
or press Cmd/Ctrl + Enter. The text is only sent to this site to match it.
Source: MDN Web Docs. Data fetched 2026-09-25T01:48:37.274Z.