Post

JavaScript
JavaScript@JavaScript·
Just curious, are you using => functions exclusively or still sticking to traditional function syntax? No judgement!
English
712
248
2.9K
0
Peter Girnus 🦅
Peter Girnus 🦅@gothburz·
@JavaScript Arrow functions since it’s neater especially if written on one line. 👨🏼‍💻
English
0
0
1
0
Marcel
Marcel@marcelkargul·
@JavaScript I use normal function syntax but for array methods and stuff i use arrow syntax as it looks a lot cleaner
English
0
0
1
320
Luis H. Ball Jr.
Luis H. Ball Jr.@luqven·
@JavaScript I now default to arrow functions instinctively but can’t say I “prefer” one over the other.
English
0
0
0
0
Andrew Rowley
Andrew Rowley@internet_drew·
@JavaScript Starting to use them for any instance in which I don’t need to worry about what ‘this’ is bound to.
English
2
0
30
0
TiiL
TiiL@MzTeel·
@JavaScript I dnt have a preference yet. I’m still fighting for my life learning the material. 🤣
English
0
0
13
0
Tyler Smith
Tyler Smith@tylerlwsmith·
@JavaScript 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.
English
0
0
11
0
Mahmoud
Mahmoud@interakt_dev·
@JavaScript Does using one over the other make any difference to the code?
English
4
0
10
0
Web Guy Jeff
Web Guy Jeff@WebGuyJeff·
@JavaScript 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 😁
English
1
0
10
0
Subhasis Das
Subhasis Das@inframarauder·
@JavaScript 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.
English
0
0
7
0
Cameron N
Cameron N@ccnokes·
@JavaScript `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 😁.
English
1
0
5
0
Kyriakos Markakis
Kyriakos Markakis@marquicodes·
@JavaScript 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.
English
2
0
5
0
drainpipe
drainpipe@drainpipe_·
@JavaScript For tiny bits of code where the absence of 𝚝𝚑𝚒𝚜 isn't an inconvenience, sure. As a wholesale replacement for using the 𝚏𝚞𝚗𝚌𝚝𝚒𝚘𝚗 keyword, no I am not interested in trying to look cool by making everything a variable assignment.
English
0
0
5
0
Sijo Sam
Sijo Sam@mr_samdev·
@JavaScript Depends on the scope required of that function 😋
English
0
0
4
0
Hane Smitter
Hane Smitter@SmitterHane·
@JavaScript I like to take advantage of the hoisting behavior available with traditional functions
English
0
0
4
0
SSEJJEMBA
SSEJJEMBA@ssejjembadan·
@JavaScript utility functions are mostly traditional for me... but member functions are always arrow syntax as I don't want the burden of binding scope.
English
0
0
3
0
Jon Adams
Jon Adams@jamakaDev·
@JavaScript This is rather funny bc i just decided to make the switch to => yesterday! However it almost feels to clean lol
English
0
0
3
0
Esse Elemento Chamado Elenmuski
Esse Elemento Chamado Elenmuski@lucasbarreto92·
@JavaScript Both of them! I use more => functions when I'm coding in React.js and inside functions wrote in traditional syntax. I love => functions! 😁
English
0
1
1
0
Nathan Martin
Nathan Martin@NerdyMartin·
@JavaScript Yes! Use => when you want to pass the "this" context from caller to function. No if that function is ever used outside that context.
English
0
0
3
328
Austin K
Austin K@austinkdev·
@JavaScript Arrow functions are more than just syntax sugar. That being said they are my go to way to write a function unless an occasion calls for me to use the original syntax.
English
0
0
3
0
José Breijo
José Breijo@josebreijo·
@JavaScript `function` tells the reader that the line contains a function declaration, var/let/const doesn't until you keep reading. I only use arrows if I need a one-liner or to bind `this` to its lexical context, otherwise, you're adding noise to the code IMO.
English
0
0
3
0
James Tsetsekas ⚡🧡
James Tsetsekas ⚡🧡@JamesTsetsekas·
@JavaScript I use a mix of both. When its a short one I will use an arrow function to keep it compact and cleaner when I have more going on I opt for a traditionally defining function
English
0
0
2
0
แชร์