Solution Review: `this` Keyword
Explore how the this keyword behaves in different JavaScript contexts, including global scope, object methods, and constructor functions. Understand how this affects function execution and object properties, preparing you for interview questions on JavaScript object-oriented programming.
We'll cover the following...
We'll cover the following...
Question 1: Solution review
In the previous lesson, you were given the following code:
For the code above, you had to answer the following question:
Explanation
The solution is given below.
As you can see, Option D is the correct answer. Let’s discuss the code to understand the answer.
Let’s start from line 14, where we are calling obj.thisFunc.
obj.thisFunc(func, 3);
We are passing it an argument, the function func, and an extra argument, ...