When to use Normal Functions in #JavaScript?

In general, normal functions are a bit more verbose and readable compared to Arrow Functions.

Function declarations are fully hoisted, meaning you can call them before they are defined in your code. This is useful for #code organization.

Their this binding is dynamic - so "this" depends on where we call the function, not where we wrote them - which is perfect for using them as object methods and referring to specific class instances.

So, as a ...

guideline, use them for more complex logic, as object methods, or for more reusable library functions.

But there is more (as always):
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions

#programming #javascript #webdev

Functions - JavaScript | MDN

Generally speaking, a function is a "subprogram" that can be called by code external (or internal, in the case of recursion) to the function. Like the program itself, a function is composed of a sequence of statements called the function body. Values can be passed to a function as parameters, and the function will return a value.

MDN Web Docs