FAQ: Vue Data - Instance Methods

This community-built FAQ covers the “Instance Methods” exercise from the lesson “Vue Data”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Vue.js

FAQs on the exercise Instance Methods

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Regarding getters and setters, it seems as though there is a potential and problematic (infinite) loop if a get and set alter a value. That is, a get can trigger a set, and the set can trigger a get, then on and on. I assume this is to be avoided, but there’s no mention of this possibility in the lesson. I tried creating the scenario, and it seems that the get will trigger the set once. But a set can trigger the get that then triggers the set again. Maybe a few words on this topic would be helpful.

Could someone explain when to use a watcher and when to use an instance method?
I understand that event handlers are supposed to go into methods. However, in the previous exercise we used a watcher to reset hoursStudied when a new language is selected. Couldn’t that also be interpreted as an event, i.e. the click on the “Change language” button?