Episode 12: When Context And Prototypes Collide

What Happens When this Meets Prototypal Inheritance?

(It can be extremely frustrating, but not unsolvable if you know the simple rules)

Context And Prototypes

Watch The Free Preview For “The Registry Pattern”

 

Subscribe now to watch the full episode!

Get Instant Access To All Episodes »


Both JavaScript’s context (the ‘this’ keyword) and prototypes are subjects of much confusion and frustration on their own. Each of these can take an intense study and rigorous practice to master, independently of each other. But the combination of them is where the real headaches begin. When context collides with prototypes in an application, the result is often situations where you expect one thing and something completely different happens.

In this episode, you’ll see:

  • How context works with prototypes
  • How to manipulate context
  • Why order of execution matters
  • Using `hasOwnProperty`
  • Overriding prototype attributes
  • and more!

See a simplified example of how context and prototypes collide. You’ll learn how and why your code may not result in what you thought. And you’ll see a few options for solving the problems that this dynamic duo can introduce.