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 trialJesse Dispoto
Front End Web Development Techdegree Graduate 14,538 PointsWhat would happen if I created the "activity" method without the keyword "get"?
Is the get keyword only used when creating dynamically changes methods within an object? Kinda confused about "get"
1 Answer
Steven Parker
231,172 PointsLeaving off the "get" changes the access syntax. With an ordinary method, you must put parentheses after the name to invoke the method ("instance.activity()
"). But with "get" you create a dynamic property that is accessed just by name ("instance.activity
").
Jesse Dispoto
Front End Web Development Techdegree Graduate 14,538 PointsJesse Dispoto
Front End Web Development Techdegree Graduate 14,538 PointsGot it. How about order-wise? I am noticing get comes before set in many cases.... does it matter which one you invoke first?
Steven Parker
231,172 PointsSteven Parker
231,172 PointsIt looks like you asked that question separately, take a look at my answer over there.
And if this question has been answered, you can mark it solved by choosing a "best answer'.
Happy coding!