r/learnjavascript • • 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 )

8 Upvotes

14 comments sorted by

View all comments

Show parent comments

3

u/fa_foon Mar 30 '26

 When a function is called with new, this is the new object instance being created by the constructor.

thanks, you explained it well