Episode 4: Context (‘this’) In JavaScript


Watch The Free Preview For “JavaScript Context”

Subscribe now to watch the full episode!

Get FULL Access to
75+ Game-Changing Screencasts

When was the last time JavaScript’s “this” worked the way you thought it did? You have an object with a function, and you call “this” to get some data from the it only to find that the data isn’t there because “this” isn’t the object you thought it was! In this episode, we’ll look at all function invocations and how they manipulate “this”. We’ll also see some common scenarios that trip people up, like passing an object’s method as a callback.

In this episode, you’ll see:

  • 5 Function Invocations
  • Standard Function Context
  • Object Method Context
  • `.call` Context
  • `.apply` Context
  • Constructor Function Context
  • Callback Function Context
  • Bound Function Context
  • JavaScript Mixins
  • and more!

Join me as I explore and explain context in JavaScript’s functions, and show you how to bend it to your will. We’ll see how we can manipulate a function’s context directly and we’ll look at some great ways to work around the strangeness bit, including ignoring context entirely by using storing it for later, and permanently binding a function’s context to whatever we want.

  • http://anthonybrown.github.io/ Tony Brown

    Excellent overview, had to watch a few times to catch everything because so much was exampled. Is there a repo for any of your episodes?