Single Choice
Easy
QWhat does the this keyword refer to in the following code?
const user = {
name: 'John',
greet: () => {
console.log('Hello, ' + this.name + '!');
}
}
user.greet();
ID: #4914
Javascript Functions MCQ
327 views
Question Info
#4914Q ID
EasyDifficulty
Javascript Functions MCQTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer
Explanation
In this case, the greet function is an arrow function, which means that the this keyword is not dynamically bound to the object that the function is called on.
Instead, it refers to the value of this in the surrounding context, which in this case is the global object.
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic