Skip to main content
Regular parameters in JavaScript are identifiers declared within a function’s signature that act as local variables bound to the arguments passed during function invocation. They establish the function’s expected arity and provide a mechanism for data ingestion into the function’s execution context.

Parameter Binding and Arity

JavaScript does not enforce strict arity matching between the declared parameters and the provided arguments during invocation.
  • Under-application: If fewer arguments are passed than declared parameters, the unmapped parameters are automatically initialized to the primitive value undefined.
  • Over-application: If more arguments are passed than declared parameters, the excess arguments are not bound to any named identifier. They are ignored by the parameter list but remain accessible internally via the local arguments object.

The arguments Object Aliasing

In non-arrow functions, regular parameters exhibit specific aliasing behaviors with the local arguments object. This behavior diverges based on the execution mode and the complexity of the parameter list:
  • Non-Strict Mode with Simple Parameters: If the function uses a simple parameter list (no default parameters, rest parameters, or destructuring), regular parameters are dynamically mapped to the arguments object. Modifying a named parameter automatically updates the corresponding index in the arguments object, and conversely, mutating the arguments object updates the named parameter. Crucially, this bidirectional mapping only applies to arguments that were actually passed during invocation. If a parameter is under-applied (receives undefined because no argument was provided), modifying the parameter does not map it to or update the arguments object.
  • Strict Mode or Non-Simple Parameters: The dynamic mapping is completely disabled. If the function is in strict mode, or if the signature contains any non-simple parameters (ES6+), regular parameters and the arguments object remain entirely separate. Modifying a parameter identifier has no effect on the arguments object.

Evaluation Strategy

JavaScript binds arguments to regular parameters using a strict “pass-by-value” evaluation strategy.
  • Primitive Values: The parameter receives an independent copy of the primitive value. Reassigning or modifying the parameter inside the function does not affect the original argument.
  • Object Values: The parameter receives a copy of the reference pointing to the object in memory (a concept often referred to as “call-by-sharing”). Reassigning the parameter identifier to a completely new object does not affect the external reference, but mutating the properties of the referenced object will mutate the original object.

Scope and Shadowing

Regular parameters are scoped to the function’s local execution context. If a parameter shares an identifier name with a variable in an outer lexical environment, the parameter shadows the outer variable for the duration of the function’s execution.

Strict Mode Constraints

In non-strict mode, JavaScript permits duplicate parameter names within a function signature. In such cases, the last duplicated parameter shadows the preceding ones, receiving the value of the corresponding argument. However, when strict mode is enabled, declaring duplicate regular parameters results in a fatal syntax error.
Tired of Poor JavaScript Skills? Fix That With Deep Grasping!Learn More