What is created earlier var "x = 0;" or "function y () {};" in javascript?
- If memory doesn’t change, functions float higher and are executed earlier (all this on condition that both the variable and the function are created in the same scope) - Misha Saidov
- it doesn't matter if you distinguish between "declaration" and "appropriation" - Igor
|
1 answer
In the process of parsing the code, the identifiers and the var and function are stored in the VarScopedDeclaration .
Further it is possible to consider the example of a global area.
Definitions begin to go in reverse order, choosing only functions and generators (synchronous and asynchronous), and only the last defined ones remain from duplicate names.
Further definitions for variables are added.
Inside functions, the order is similar, but somewhat different.
|