2 answers
Best answer
‘This’ keyword refers to the object from where it was called.
Was this answer helpful?
Thanks for the feedback.
Sign up free to save answers and ask your own doubts
Answer: this refers to the object that is executing the current function; its value depends on how the function is called.
Common cases:
- Inside an object method:
thisis the object before the dot.const student = { name: "Riya", greet() { return "Hi " + this.name; } }; student.greet(); // "Hi Riya" - Plain function call:
thisis the global object (windowin browsers), orundefinedin strict mode. - Constructor (with
new):thisis the newly created object. - Event handler:
thisis the element that received the event. - Arrow function: it has no own
this; it usesthisfrom the surrounding code. call,apply,bind: let you setthisexplicitly.
So this is decided at call time, not where the function is written (except for arrow functions).
Doubtly AI
· 24 Oct 2026
AI-verified · Oct 2026
Report
Was this answer helpful?
Thanks for the feedback.
Sign up free to save answers and ask your own doubts
Your answer
Log in or create a free account to answer this question.