0 votes
in VueJS by
What are the  difference between computed properties and methods in Vue JS?

1 Answer

0 votes
by

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.

Related questions

0 votes
asked Oct 7, 2019 in VueJS by Tate
0 votes
asked Oct 7, 2019 in VueJS by Tate
...