Javascript

JavaScript Fundamentals -- The this Keyword

PRO
Outline

When talking about this in JavaScript, we’re talking about the context in which a JavaScript function is run. Context in general is the circumstances that form the setting for an event, statement, or idea. So in JavaScript, it’s the circumstances in which a function is run.

We deal with context all the time in daily conversation. We use words like it, and he, or she all the time, and if someone was listening in to the conversation but didn't know what the context was, they wouldn't know what you were talking about. Understanding the context of the conversation is vital to understanding the conversation itself. It's the same in JavaScript. To truly understand what's happening in a function, you need to understand what context it is being run in.

The same function can be run in multiple contexts. In this example, we look at running the sayHello function in the global context and in the context of a person object. In the next few videos, we'll talk about this in more depth, but I wanted to point out that the same function can be run in different contexts; the context is determined the circumstances in which the function is run.

For more information on this in JavaScript, go read this blog post.

 

I finished! On to the next chapter