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 trialJonathan Ambriz
Courses Plus Student 3,902 PointsSpace.js doesn't have token as an input variable.
Is it safe to say that only variables that are assigned with this.x = x format should be passed as variables to the constructor? I had placed token into the constructor call. Why was it left out?
1 Answer
Clinton Hays
Front End Web Development Techdegree Graduate 18,156 PointsHey Jonathan Ambriz ! Token wasn't explicitly declared in the constructor because it is a dynamic property. We don't yet know the id of the token that could fill this space. If we declare the token property in the constructor, we wouldn't be able to change the token in each space on the fly, we would have to code every space with every possible token. Leaving token out of the constructor allows us to populate that property dynamically.
Hope this helps! Happy coding.