Skip to content

SyntaxError: Duplicate parameter name not allowed in this context

Error message

                Duplicate parameter name not allowed in this context
              

Quick summary

You declared a function with duplicate parameter names while in strict mode — this is not allowed.

Why this happens

  • A function has two parameters with the same name in strict mode

  • An arrow function or class method has duplicate parameter names

  • Code was converted to strict mode (e.g., by adding 'use strict' or using ES modules)

Minimal example

✗ Broken code
"use strict";
function add(a, a) {
  return a + a;
}
✓ Fixed code
"use strict";
function add(a, b) {
  return a + b;
}

In strict mode, duplicate parameter names are not allowed. Rename the second parameter.

How to diagnose

  • Check the function's parameter list for duplicate names

  • Verify if the code is running in strict mode (modules and classes always are)

  • Look for parameters that were accidentally given the same name

How to fix

  • Rename one of the duplicate parameters

  • Use a rest parameter or options object instead of many parameters

How to prevent

  • Use descriptive, unique parameter names

  • Consider using an options object for functions with many parameters

Related Resources

Related Glossary

Related Lessons

← Back to language