Recall & Review
beginner
What is a computed property in Vue?
A computed property is a special function that automatically calculates and updates a value based on reactive data. It caches the result and only recalculates when its dependencies change.
Click to reveal answer
beginner
Why use computed properties instead of methods for derived state?
Computed properties cache their results and only update when dependencies change, making them more efficient than methods, which run every time they are called.
Click to reveal answer
intermediate
How do you define a computed property using the Composition API in Vue 3?
You import the 'computed' function from 'vue' and pass a function that returns the derived value. Example: const fullName = computed(() => firstName.value + ' ' + lastName.value);Click to reveal answer
beginner
What happens if a computed property depends on reactive data that changes?
The computed property automatically recalculates its value and updates any parts of the UI that use it, keeping the interface in sync with the data.
Click to reveal answer
intermediate
Can computed properties have setters in Vue? What is their use?
Yes, computed properties can have setters to allow two-way binding. The setter lets you update the underlying reactive data when the computed property is assigned a new value.
Click to reveal answer
What does a computed property in Vue do?
✗ Incorrect
Computed properties calculate values based on reactive data and cache the result until dependencies change.
Which Vue API is used to create a computed property in Vue 3 Composition API?
✗ Incorrect
The computed() function creates computed properties that derive values from reactive data.
When does a computed property recalculate its value?
✗ Incorrect
Computed properties recalculate only when their reactive dependencies change, improving efficiency.
What is the benefit of using a computed property over a method for derived state?
✗ Incorrect
Computed properties cache their results and only update when dependencies change, unlike methods.
Can computed properties in Vue have setters?
✗ Incorrect
Computed properties can have setters to update reactive data, enabling two-way binding.
Explain how computed properties help keep the UI in sync with data in Vue.
Think about how Vue tracks changes and updates the screen.
You got /4 concepts.
Describe how to create a computed property using Vue 3 Composition API and why it is preferred over methods for derived state.
Focus on the syntax and benefits of computed properties.
You got /4 concepts.