Honestly, you should never use a function before its declaration (hoisting or not).
The first is indeed the "default" one. It just put a new function into the scope.
For the second, I see two tiny benefit:
You can assign a long and descriptive function name to a shorter variable name. That way, your debugger with put the long function name in stack trace and your code can play with a simpler version.
// Don't go too short neitherconstfetch=functionfetchAllUsersFromDataBase(){/* ... */}constfilter=functionkeepOnlyActiveUsers(){/* ... */}returnPromise.all([fetch,filter]);
You can use the non-scoping property or arrow function. Using this inside an arrow function refer to the wrapping scope.
Honestly, you should never use a function before its declaration (hoisting or not).
The first is indeed the "default" one. It just put a new function into the scope.
For the second, I see two tiny benefit:
this
inside an arrow function refer to the wrapping scope.Finally, IIFE don't declare a new function. That's indeed just a way to do "private" scoping.