0

Is it a good convention to write the following function:

const funcName = function funcName(){
....
}

I read that one should use function expressions and not function declarations, and it's a bad idea not to give a function a name. The problem I have is that I don't want to give a different name for a function and a different name for a variable, so I used the same name. Is it OK?

CrazySynthax
  • 13,662
  • 34
  • 99
  • 183
  • There is a time and a place for all coding styles. To make a blanket statement that function declarations are bad is reckless. With function expressions, you have the problem of hoisting that causes you to not be able to call a function before you declare it. If you don't use anonymous functions you lose a lot of flexibility. Also, this question will most likely get closed since it is not a programming problem that you need help with, which is what Stack Overflow is for. – Scott Marcus May 04 '17 at 14:31
  • That dependeds on the code style you are using. For example: https://github.com/airbnb/javascript#functions – str May 04 '17 at 14:34

0 Answers0