Skip to content
JS
JavaScript error

SyntaxError

The JavaScript strict mode-only exception "for-in loop head declarations may not have initializers" occurs when the head of a for...in contains an initializer expression, such as for (var i = 0 in obj). This is not allowed in for-in loops in strict mode.

Reference entryJavaScriptFetched
SyntaxError: for-in loop variable declaration may not have an initializer. (V8-based)
As listed by MDN Web Docs
SyntaxError: for-in loop head declarations may not have initializers (Firefox)
As listed by MDN Web Docs
SyntaxError: a lexical declaration in the head of a for-in loop can't have an initializer (Firefox)
As listed by MDN Web Docs
SyntaxError: Cannot assign to the loop variable inside a for-in 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.