Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Sam Bailey](https://secure.gravatar.com/avatar/abccc2b0c0bac857b45ae652de6ad217?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Sam Bailey
8,425 PointsWhy does this.owner = owner not work?
I'm having trouble understanding why we have to use the "backing property" of _owner, in place of owner. The constructor allows us to set, for example, this.animal = animal, so why can't we use the same syntax within the setter?
When I try it in the workspace, it gets a "Maximum call stack size exceeded" error, but I'm not sure why.
On an unrelated note, I find it a but odd that there are no other questions on this video... did they all get deleted or something? This topic is not exactly straightforward...
3 Answers
![Jonathan Grieve](https://uploads.teamtreehouse.com/production/profile-photos/601842/micro_twitterCover.png)
Jonathan Grieve
Treehouse Moderator 91,253 PointsThe purpose of the backing property is explained in the video. :-)
Backing properties go with setter()
methods in OOP JavaScript. You need property and value that is equal to the single parameter that is passed to the method. That's how setter methods work. But you can't use exact names in the method, which is why the convention is to add an underscore to the name of the value.
The name of the property can never be the same as the name of a getter or setter method
I'm not exactly sure why this is. It's similar I think as to why you can't use variable names that are the same as JavaScript keywords. But the backing property is the thing that solves the issue.
![Jesse Evans](https://secure.gravatar.com/avatar/3d24362931f800c75d6348f724fe3c97?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Jesse Evans
Full Stack JavaScript Techdegree Student 8,967 PointsHI Sam -
I'm not confident I have the answer as I'm pretty green but here's where I am at trying to understand myself:
- maximum call stack size exceeded typically happens when some recursion won't resolve. e.g.: function knockKnock(){ console.log('who is there?'); console.log('Banana'); console.log('Banana who?'); knockKnock();}
- from looking at the setter code:
set owner(owner) {
this.owner = owner;}
I think what happens here is when we try to assign a value to owner, with "ernie.owner = 'Ashley';", the setter takes the argument owner, which then would be the right side of "this.owner = owner", but this.owner is taken as a call to the setter method which is then repeating the same thing again, never using the argument owner, before this.owner calls the setter again. - So i think change owner to _owner is a way to 'have orange knock on the door'/prevent unreconcilable recursion, since specifically, this.owner isn't a container that just needs a value, it's the setter method being called [the same way ernie.owner calls the method]. "this" is equivalent to "ernie" but just inside the object/class.
That's where I ended up pondering your question, I hope that helps, or that someone else can chime in and correct me if I am wrong.
![Justin Kao](https://uploads.teamtreehouse.com/production/profile-photos/11647281/micro_S__5799939.jpg)
Justin Kao
5,724 PointsWell.. That error is also called Stack Overflow
Because when you return this.owner
you're not calling the property
You're calling the METHOD set owner()
function
and guess what, that's an infinite recursion
so when computer memory gets full, you get the error Maximum call stack size exceeded
BTW, use markdown to mark your question, otherwise it's really hard to have a quick browse LOL