0

Better const or function

I personally find more intuitive to declare a function with the ‘function’ keyword. What is the standard? Should I use function over const to declare a function that doesn’t fit in one line?

6th Oct 2021, 9:04 AM
Davide Taffarello
Davide Taffarello - avatar
1 Resposta
+ 3
Please tag the relevant programming language. In JS it is possible to declare a function as const. Some relevant aspects to consider can be found in this stackoverflow thread: https://stackoverflow.com/questions/33040703/proper-use-of-const-for-defining-functions#33040926 In short: const prevents overriding a function but does not handle this-binding as you probably would want. I'd say: use const for function only if you really want it and really know what you do.
6th Oct 2021, 9:51 AM
Lisa
Lisa - avatar