I have a question about this:
According to what I have read, the declared functions are available for your call regardless of their position in the code.
Even if the declaration is at the end of a whole source code, it will take precedence over those expressions that precede it.
However, if we deal with expressed functions, they are only evaluated when the natural flow of execution reaches them.
In ECMASCRIPT6 this is still literally like this? Because in the following example, the web where I found the information describes:
Since the function is created before the code is evaluated, in some browsers we can find that we skip the conditional and the foo function is always assigned the value FALSE, which it would correspond with the last call made.
myVar=true;
if( myVar == true){
function foo(){ return 'TRUE'; }
}else{
function foo(){ return 'FALSE'; }
}
console.log(foo());
When I try the above, contrary to what is said, the result is TRUE.
Do you really have to find if you create a function in one way or another, or on the contrary you choose mostly for the declaration (as in almost all projects I find)?