Parameters & Default

Master this topic with zero to advance depth.

Expert Answer & Key Takeaways

Mastering Parameters & Default is essential for high-fidelity technical architecture and senior engineering roles in 2026.

JavaScript Function Parameters

A JavaScript function does not perform any checking on parameter values (arguments).

1. Parameters vs Arguments

  • Function Parameters are the names listed in the function definition.
  • Function Arguments are the real values passed to (and received by) the function.

2. Default Parameters

If a function is called with missing arguments (less than declared), the missing values are set to undefined. ES6 allows function parameters to have default values:
function myFunction(x, y = 10) { return x + y; } myFunction(5); // Returns 15

3. The Arguments Object

JavaScript functions have a built-in object called the arguments object. It contains an array of the arguments used when the function was called.
function findMax() { let max = -Infinity; for (let i = 0; i < arguments.length; i++) { if (arguments[i] > max) { max = arguments[i]; } } return max; }
[!WARNING] The arguments object is not a real Array. It looks like one but doesn't have methods like map or forEach.

4. The Rest Parameter (...)

The rest parameter (...) allows a function to treat an indefinite number of arguments as an array:
function sum(...args) { let sum = 0; for (let arg of args) sum += arg; return sum; } let x = sum(4, 9, 16, 25, 29, 100, 66, 77);

Top Interview Questions

?Interview Question

Q:What happens if you pass more arguments than parameters?
A:
JavaScript doesn't throw an error. The extra arguments are ignored by the named parameters, but they are still accessible via the 'arguments' object or the rest parameter.

?Interview Question

Q:How do you set a default value for a parameter?
A:
You can assign a value directly in the function header: function myFunc(a = 1, b = 2) { ... }

?Interview Question

Q:What is the difference between the 'arguments' object and Rest parameters?
A:
The 'arguments' object is a local variable available within all functions (except arrow functions) and is array-like, but not a real array. Rest parameters (...args) are actual arrays and are the modern standard for handling indefinite arguments.

Course4All Engineering Team

Verified Expert

Senior Full-Stack Engineers & V8 Experts

Our JavaScript and engine-level content is developed by a collective of senior engineers focused on high-performance web architecture and 2026 standards.

Pattern: 2026 Ready
Updated: Weekly