What error does re-declaring let in the same scope throw in JavaScript?
SyntaxError: Identifier 'x' has already been declared. The engine catches the duplicate declaration at parse time, before any code runs.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in SyntaxError vs ReferenceError vs TypeError in JavaScript
SyntaxError is caught at parse time (malformed code, const without initializer, re-declaration). ReferenceError is at runtime (variable does not exist or is in TDZ). TypeError is at runtime (value is wrong type for the operation, reassigning const).
Because the engine catches it during parsing, before any code runs. 'const x;' is malformed syntax (const requires an initializer), so it is a SyntaxError, not a runtime ReferenceError.
Because the variable exists (no ReferenceError), but the operation (assignment) is not allowed for a const. The value's type (const binding) does not support reassignment, so it is a TypeError.
Still have questions?
Browse all our FAQs or reach out to our support team
