The Four Binding Rules Preview
What you'll learn: How JavaScript decides what this means using four distinct binding rules that apply in different situations.
Now that you understand this uses dynamic binding (determined at call-time, not write-time), you need to know how JavaScript actually determines what this will be. The answer: JavaScript follows one of four binding rules — and they're applied in a specific priority order.
The Four Rules
Think of these rules as a decision tree JavaScript walks through every time a function using this is called:
- Default Binding — What happens when none of the other rules apply (the fallback case)
- Implicit Binding — When a function is called as a method on an object
- Explicit Binding — When you manually specify what
thisshould be using special functions - New Binding — When a function is called with the
newkeyword
Why Four Rules?
JavaScript gives you multiple ways to invoke functions, and each invocation pattern needs a clear rule for determining this. Having four distinct, prioritized rules means there's always a definite answer to "what is this?" — you just need to identify which rule applies to the current function call.
The Priority System
When multiple rules could apply, JavaScript has a priority order (which we'll explore in detail later). This ensures predictable behavior: the same function call will always bind this the same way.
Key Takeaway: JavaScript determines this using one of four binding rules — default, implicit, explicit, or new — applied in priority order based on how the function is called, not where it's written.