1.

What are the uses of computed properties in Vue.js?

Answer»

A computed property is  one of the powerful features from Vue that enables US to transform our data by performing calculations on the VALUE of the data and then easily REUSING the result as an up-to-date variable in our template.

Computed properties have the FOLLOWING usage: 

  • saves us from putting too much logic in our templates which might make them hard to maintain 
  • Computed properties are cached based on reactive dependency. If there is no CHANGE in the value of reactive data the previously cached value is used rather than recomputing the result which increases performance.  
  • allows us to reuse a logic if it is needed more than once in the template rather than repeating the logic everywhere 
  • is recommended for complex logic that includes reactive data 


Discussion

No Comment Found

Related InterviewSolutions