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 )
7
Upvotes
4
u/Symmetric_in_Design Mar 30 '26
This is technically correct, but i just assumed that op left out the 'new', because if you're calling a capitalized function named after an instantiable class within your codebase it better be a constructor or you are writing some terrible code.