Course contentsShow
← JavaScript
Lesson 400 of 2,72311. FunctionsFree lesson

Arrow Functions and the Arguments Object

Understand that arrow functions don't have their own 'arguments' object but inherit it from outer scope.

What You'll Learn

You'll discover why arrow functions don't have their own arguments object and what that means for accessing function parameters.


Arrow Functions Don't Create Arguments

In traditional functions, JavaScript automatically provides an arguments object—a special array-like object containing all the arguments passed to the function. Arrow functions break this pattern: they don't get their own arguments object at all.

Instead, if you reference arguments inside an arrow function, JavaScript looks outward to the surrounding (outer) scope, just like it does with this.


Practical Impact

In a regular function:

function regularFunc() {
  console.log(arguments[0]); // "hello"
}
regularFunc("hello", "world");

In an arrow function:

const arrowFunc = () => {
  console.log(arguments); // ReferenceError (if no outer scope)
};
arrowFunc("hello", "world"); // Error!

Arrow function inside a regular function:

function outer() {
  const inner = () => {
    console.log(arguments[0]); // "outer-arg" (from outer!)
  };
  inner();
}
outer("outer-arg");

The arrow function inner doesn't have its own arguments, so it borrows from outer.


Why This Matters

Think of arrow functions as "lightweight" functions that inherit context from their surroundings. They're perfect for callbacks and short operations, but when you need direct access to all passed arguments, use a regular function or rest parameters (which you'll learn later).


Key Takeaway: Arrow functions don't have their own arguments object—they inherit it from the nearest outer function scope, or cause an error if none exists.