Lingua-e
JavaScript

What is a Identifier Already Declared?

← Errors

This SyntaxError is thrown when let or const is used to declare a variable name that already exists in the same scope. Unlike var, which silently allows redeclaration, let and const enforce unique names within a block scope.

Why it happens

  • Declaring the same variable twice with let or const in the same block.
  • A variable name collides with a function parameter in the same scope.
  • Copy-pasting code that introduces a duplicate declaration.
  • Bundling or transpilation that puts two modules' variable names in the same scope.

Examples

JavaScript

Code that triggers the error

let count = 0;
let count = 1; // redeclaration in same scope

Error output

SyntaxError: Identifier 'count' has already been declared

How to fix it

To update an existing variable, use assignment (=) without a declaration keyword. If you need a new variable in a nested scope, wrap it in a block ({}). Rename one of the conflicting variables if they serve different purposes.

Fixed code

let count = 0;
count = 1; // reassign, not redeclare

Related errors

Ready to practice your English at work?

Lingua-e has interactive exercises built around real developer conversations: standups, code reviews, retrospectives, and more. Practice until it comes naturally.

Try Lingua-e for free