0

When learning js, I know that function expressions can help with hoisting problem solving and performance.

Most of the function expressions I'm talking about are expressed using arrow functions.

In addition, ESLint's popular rule, airbnb, recommends the use of function expressions.

However, it is described as a function declaration in the official documentation of the library such as react and next.

The grammar from the official document is not the correct answer, but I think it was written through at least a lot of thoughts and research. Other js developers have also seen examples of using function declarations.

Because of performance and hoisting issues, it looks good to write them all as function expressions. Why is there a case for using function declarations?

Most of them say they are similar and have a difference in style, but I didn't get a cool answer.

Personally, I couldn't find a reason except that function declarations are similar to common programming languages, and they refer to functions more clearly, which helps readability.

I am so curious about the reason. If you know, thank you for giving me insight!

Kyungeun Park
  • 113
  • 1
  • 10
  • A regular `function` can be called before it's defined. Not so, of an Anonymous or arrow function. – StackSlave May 21 '21 at 01:00
  • https://stackoverflow.com/questions/34361379/are-arrow-functions-and-functions-equivalent-interchangeable – Daniel Duong May 21 '21 at 02:07
  • 2
    Does this answer your question? [Are 'Arrow Functions' and 'Functions' equivalent / interchangeable?](https://stackoverflow.com/questions/34361379/are-arrow-functions-and-functions-equivalent-interchangeable) – Daniel Duong May 21 '21 at 02:07

0 Answers0