r/learnjavascript • u/fa_foon • Mar 30 '26
question about `this.`
i understand that `this` refers to the caller of the function so how can `name` in `function Person(name){this.name = name;}` be assigned to `Person` since no object is calling
(this wasn't explained in that comment )
10
Upvotes
View all comments
Show parent comment
1
u/Umustbecrazy Apr 02 '26
In Event handlers , using regular functions as callbacks (non arrow), 'this' will be the element calling the event, so it's not always undefined as a callback. The exception I'm sure you are aware of.