Skip to content
JS
JavaScript error

ReferenceError

The JavaScript exception "can't access lexical declaration 'X' before initialization" occurs when a lexical variable was accessed before it was initialized. This happens within any scope (global, module, function, or block) when let or const variables are accessed before the place where they are declared is executed.

Reference entryJavaScriptFetched
ReferenceError: Cannot access 'X' before initialization (V8-based)
As listed by MDN Web Docs
ReferenceError: can't access lexical declaration 'X' before initialization (Firefox)
As listed by MDN Web Docs
ReferenceError: Cannot access uninitialized variable. (Safari)
As listed by MDN Web Docs
Category
ReferenceError
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.273Z.