Just curious, are you using => functions exclusively or still sticking to traditional function syntax? No judgement!
I sometimes like old ones for hoisting or inline util functions
Arrow functions since it’s neater especially if written on one line. 👨🏼💻
I use normal function syntax but for array methods and stuff i use arrow syntax as it looks a lot cleaner
I now default to arrow functions instinctively but can’t say I “prefer” one over the other.
For callbacks, arrow function. For function declaration, normal function
Starting to use them for any instance in which I don’t need to worry about what ‘this’ is bound to.
It takes me 5x more time to understand the syntax everytime I try to use that. Traditional function() is longer but more comfortable
I dnt have a preference yet. I’m still fighting for my life learning the material. 🤣
I learnt the modern before i knew there was a traditional, lol
I default to the "function" keyword for most things. Hoisting is helpful for module-level functions. For inline callback functions/closures, I like that the function keyword allows me to give the function a descriptive name.
Depends on the circumstance. Anonymous functions use =>. If I want my reader to better understand the purpose of a function, I'll use traditional.
Does using one over the other make any difference to the code?
Both, because it's required - they aren't equal. One such example of where arrow functions catch me out, is in event listener callbacks. Arrow functions don't bind 'this', which can lead to debugging hell when I forget 😁
Arrow functions because I like that functions are just values.
Mostly fat arrow (=>) functions. The only time I use traditional functions(function()) is when I need the scope of 'this' to be the function itself, instead of global scope. I guess that's a major difference between the two approaches that really sets apart their use cases.
When passing a #JavaScript function as an argument, its better to use the phatarrow syntax. Inside of a class, or global scope, its better for writing an "easy 2 use & understand lexical scope", and for printing better stacktraces to use the C-Style functions.
Arrow functions and function declarations have slightly different behavior, so it depends on the use case.
`function` keyword for everything but one-liners and inline functions (e.g callbacks on array methods, etc). The function keyword is plenty terse and the hoisting behavior is useful. I'm also positive this is the only correct opinion to have 😁.
Probably quite unpopular but I prefer the traditional function syntax: function doSomething (x, y) { ... } I use arrow functions mostly for one liners and some trivial callbacks.
Hey Js, It'd look cool if you add <= for return statements, coz => is used for functions. 🤌
You can’t use arrow functions with hoisting so in those cases I use old school functions
I like to take advantage of the hoisting behavior available with traditional functions
Mostly arrow functions for callbacks definitely...
United States الاتجاهات
- 1. #heatedrivalry 104K posts
- 2. Rams 79.8K posts
- 3. ilya 91K posts
- 4. Andrea 30K posts
- 5. Puka 53.6K posts
- 6. Sam Darnold 21.2K posts
- 7. Ben Shapiro 51.2K posts
- 8. svetlana 8,815 posts
- 9. #PowerForce 1,739 posts
- 10. SCOTT HUNTER 14.9K posts
- 11. Stafford 22.7K posts
- 12. #zzzSpecialProgram 7,960 posts
- 13. jacob tierney 7,045 posts
- 14. Al Michaels 3,016 posts
- 15. Portuguese 32.3K posts
- 16. Rose 170K posts
- 17. #zzzero 37.3K posts
- 18. #TSTheEndOfAnEra 11.6K posts
- 19. connor storrie 18.5K posts
- 20. Lifesaving 3,548 posts
Something went wrong.
Something went wrong.