Oct 9, 2019 in Vue.JS
Q: What are the  difference between computed properties and methods in Vue JS?

1 Answer

Oct 9, 2019

Computed properties are getter function in Vue instance rather than actual methods. we can define the same function as a method instead. However, the difference is that computed properties are cached based on their dependencies. A computed property will only re-evaluate when some of its dependencies have changed. In comparison, a method invocation will always run the function whenever a re-render happens.

When we have to compute something by doing lot of computations like looping through a large array, it is best to use computed properties instead of a method. Without caching, we would spend more time than necessary. When we do not want cache, we can use a method instead.

Click here to read more about Vue JS
Click here to read more about Insurance

Related questions

Oct 7, 2019 in Vue.JS
Oct 7, 2019 in Vue.JS
Oct 1, 2019 in Vue.JS