A function declaration is declared (therefore, it can be called earlier in the code, then it is defined), the function operator is not.
Does JavaScript execute the functions defined in the script file, regardless of whether they are called by the event handler?
The function is called when it is called. Either because something has theFunction followed by () (possibly with arguments), or because it is made by an event handler.
onload="function"
If it's JS, then it assigns a string to something waiting for the function. If this is HTML, you need to () call the function.
And finally, if a function is defined in another function, when the parent function is called, is the lower function also called?
Not. A function is called only when it is called. Declaring a function inside another limits the scope.
source share