Thursday, October 23, 2025
HomeLanguagesJavascriptJavaScript SyntaxError – Redeclaration of formal parameter “x”

JavaScript SyntaxError – Redeclaration of formal parameter “x”

This JavaScript exception redeclaration of formal parameter occurs if a variable name is a function parameter and also declared again inside the function body using a let assignment.

Message:

SyntaxError: Let/Const redeclaration (Edge)
SyntaxError: redeclaration of formal parameter "x" (Firefox)
SyntaxError: Identifier "x" has already been declared (Chrome)

Error Type:

SyntaxError

Cause of Error:  In a function declaration, a variable name in the function parameter and inside the function body, same variable name declared using a let assignment.

Example 1: In this example, the ‘let’ keyword is used to re-declare the parameter variable, So the error has occurred.

HTML




<!DOCTYPE html>
<html>
<head>
    <title>Syntax Error</title>
</head>
<body>
    <script>
    function GFG(var_name) { 
      let var_name = 'This is GFG';
      return var_name;
    }
    document.write(GFG());
    </script>
</body>
</html>


Output(In console):

SyntaxError: Let/Const redeclaration

Example 2: In this example, the ‘const’ keyword is used to re-declare the parameter variable, So the error has occurred.

HTML




<!DOCTYPE html>
<html>
<head>
    <title>Syntax Error</title>
</head>
<body>
    <script>
    function GFG(var_name) { 
      const var_name = 12345;
      return var_name;
    }
    document.write(GFG());
    </script>
</body>
</html>


Output(In console):

SyntaxError: Let/Const redeclaration
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS