Course contentsShow
← JavaScript
Lesson 545 of 2,72314. The 'this' KeywordFree lesson

Preview: Arrow Functions Break the Rules

Introduction to how arrow functions use lexical 'this' binding, different from regular functions.

Preview: Arrow Functions Break the Rules

You'll learn that arrow functions handle this completely differently from regular functions—they don't follow the four binding rules at all.

A Different Kind of Function

Everything you've learned about this so far applies to regular functions. Arrow functions (=>) are different animals entirely. Instead of determining this dynamically based on how they're called, arrow functions use lexical binding for this—just like regular variables.

Think of it this way: Regular functions are like chameleons that change their this color depending on where you put them. Arrow functions are like painted statues—their this is fixed when they're created, based on the surrounding code.

What "Lexical" Means Here

When an arrow function is created, it captures the this value from its enclosing scope (the function or context it was written inside). That captured value never changes, no matter how or where you call the arrow function later.

This is the same "lexical scope" concept you learned with closures—but now it applies to this instead of regular variables.

Why This Matters

Regular functions give you dynamic this based on the call-site. Arrow functions give you predictable this based on where they're written. Neither is "better"—they're tools for different jobs. Understanding when each approach helps is crucial for avoiding this confusion.

Key Takeaway: Arrow functions don't use the four binding rules for this—they capture this lexically from their surrounding scope at creation time, making their behavior predictable but inflexible.