The history teaches us that the compiler processes the code in three stages:
Lexing
As in the image above, in this phase, we convert our program into meaningful tokens.
Parsing
Here we take a stream of tokens (array) and trasform it into an abstract syntax tree called AST that represent the grammatical structure of the program.
Code Generation
Here JavaScript convert AST into a set of machine instruction.
Between parsing and code generation, JavaScript optimizes performance, execution and does also other cool stuff, all in a millisecond.
If you want take time to understand JavaScript engines look this awesome video from JS config Franziska Hinkelmann
Top comments (0)