"Identifier has already been declared" in JavaScript — What It Means and How to Fix It
What the JavaScript error "Identifier has already been declared" means and how to fix it.
Published October 30, 2026
"Identifier has already been declared" is occurs when let or const is used to declare a variable name that already exists in the same scope.
Key points
- Check the browser console's stack trace to find exactly which line and call triggered the error
Example
let x = 1;
let x = 2; // SyntaxError: Identifier 'x' has already been declared