On learn.js it is written:
The execution of the script occurs in two phases:
In the first phase, initialization takes place, preparing for launch.
During initialization, the script is scanned for the declaration of functions of the type Function Declaration, and then for the declaration of var variables. Each such ad is added to the window.
Functions declared as Function Declaration are created immediately, and variables equal to undefined.
In the second phase - actually, implementation.
The assignment (=) of variable values occurs when the execution thread reaches the corresponding line of code, until then they are undefined.
And I also answered stackoverflow that:
The work of any script in javascript consists of two phases. The first is the parser, which looks at all the input text and prepares the script for execution, translates it into an internal representation. In the second phase, this internal representation begins to run.
- Is it true that we are talking about the same phases?
- If yes, then in the first phase not only the parser works, but initialization also occurs?
- Bulk please, what phases are there at all? And what happens during each phase?
ParseScript
is first executed, and then, if there were no errors, ScriptEvaluation - Grundy pm