Skip to content

Duplicate Catch Parameter Name

Quick summary

You used the same identifier for two parameters — strict mode forbids duplicate parameter names.

Why this happens

  • Copy-paste error that repeated a parameter name

  • Renaming a parameter but forgetting to update all occurrences

  • Using a catch parameter name that shadows a binding in the same scope

Minimal example

✗ Broken code
function update(x, x) { // SyntaxError in strict mode
  return x;
}
✓ Fixed code
function update(x, y) {
  return y;
}

Both parameters are named x, which strict mode rejects. Renaming the second to y makes the signature valid.

How to diagnose

  • Read the SyntaxError: 'Duplicate parameter name not allowed in this context'

  • Inspect the function/catch signature for repeated names

  • Use the editor's rename feature to find all occurrences

How to fix

  • Rename one of the duplicate parameters to a distinct name

  • Use rest parameters or an options object instead of many positional params

  • Wrap the catch in its own block scope to avoid shadowing

How to prevent

  • Use distinct, descriptive parameter names

  • Run a linter that flags duplicate parameter names

Related Resources

Related Glossary

Related Lessons

← Back to language