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 trialJulianna Kahn
20,702 PointsI can't tell from this video, is the Owner class being created "inside" the Pet class.
I'm trying to understand if a class can be set up inside a class.
3 Answers
Ian Ostrom
Full Stack JavaScript Techdegree Student 10,332 PointsThink of the class as the mold and the object is what is mass produced by that mold. Both the owner and pet classes are independent. When the objects of each are created (instantiated) they each are a new entity with its own space in the memory of the computer.
When we call the owner setter method on the ernie object we are connecting the ashley object to it by referencing it in ernie's _owner property.
Julianna Kahn
20,702 PointsI don't understand when you say you can use a getter to use another class "inside that" class.
Owen McComas
8,472 PointsNope, classes cannot be nested in other classes. But you can use a getter though to use another class inside that class.
Julianna Kahn
20,702 PointsJulianna Kahn
20,702 PointsThat explains a lot, thank you.