DEV Community

Discussion on: What is "this"? Why you should avoid arrow functions on Vue methods

Collapse
 
christiankozalla profile image
Christian Kozalla

Interesting. But I still code in Vue v2 and frequently use 'this' with regular functions. What's the point of giving up 'this' in favor of arrow functions, when it still works the way it is?

Collapse
 
iamschulz profile image
Daniel Schulz

If it works for you, then great :) I'm not telling you to refactor your entire codebase.

this is context aware and changes its meaning depending on its scope. That's inherently hard to read and understand.
Scope is also a problem that gets simpler with arrow functions, because they inherit their parent scope and don't create their own.
The point in giving up this is writing more readable code.