Earlier in this class, we asked the very important question, what is context in JavaScript? And we found the answer was context is the object to which a method belongs. That discussion was fairly high levels. Let's dig in a little bit deeper. Here I have this object called account. And it has two properties, account number, which is a number and get account number, which is a function.
In JavaScript. When a property is a function. It's also called a method that happens to be true for a number of languages. But here the get account number property is a method because it's a function and that function returns the value of the account number property of this object. So in this case, it will return 12345. Now we could have just said in our get account number method, return account dot account number, but that's not very elegant.
So what we do as we say return this dot account number now since get account number is a method, the JavaScript This keyword inside of that method refers to the object to which that method belongs. And that method belongs to the account object. So the get account number method returns the account number property of whatever object it belongs to, which happens to be the account object. So when we say this dot account number, we're really saying account dot account number. So it's just really important to remember that when it comes to context, the JavaScript this keyword refers to the object to which a method belongs. Now let's dig in a little bit deeper and look at some actual code examples.