Today I finally sat down to figure out the difference between Normal Functions and Arrow Functions in JavaScript. 😅 If you're like me and thought it was just about saving a few keystrokes, here is what I learned: 🛑 Normal Functions (function) Flexible this: The value of this changes depending on how you call the function. Constructors: You can use them with new to create objects. Hoisting: You can call them before they are even defined in your code. ⚡ Arrow Functions (=>) Predictable this: They "inherit" this from the code around them. No more .bind(this) hacks! Clean Code: Great for one-liners and array methods like .map() or .filter(). No arguments: They don't have their own arguments object (use ...rest instead). My takeaway: Use Normal functions for object methods and Arrow functions for almost everything else (especially callbacks). #JavaScript #LearningToCode #WebDev #CodeNewbie #Programming
i always just use normal functions
I had exact same moment few years ago, while troubleshooting an issue on Vue component, I found exactly what you did.