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
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.
Though I’m into Functional Programming, I still prefer function(){} 😅
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
United States 趨勢
- 1. Bama 22.2K posts
- 2. Oklahoma 42.1K posts
- 3. Mateer 6,948 posts
- 4. Woodley 10.8K posts
- 5. Anderson Silva 6,423 posts
- 6. Epstein 978K posts
- 7. #CFBPlayoff 9,831 posts
- 8. #JakeJoshua 23.2K posts
- 9. Bill Clinton 125K posts
- 10. Ty Simpson 2,406 posts
- 11. #SmackDown 14.3K posts
- 12. DeBoer 5,751 posts
- 13. #RollTide 7,254 posts
- 14. Maxey 3,172 posts
- 15. Sixers 4,344 posts
- 16. Ryan Williams N/A
- 17. #BoomerSooner 7,536 posts
- 18. Chris Finch N/A
- 19. VJ Edgecombe 1,077 posts
- 20. Venables 1,522 posts
Something went wrong.
Something went wrong.