How V8 executes JavaScript
From source code to processor instructions.
Consider the expression const damage = 2 + 3;. It is a short statement for a person. For the engine, it starts as a sequence of characters. The scanner recognizes tokens, the parser builds the program’s structure, and the bytecode generator turns it into executable instructions.
In V8, initial execution usually involves Ignition. Some code may later receive a machine-code version, prepared quickly by a baseline compiler or optimized more extensively.
Different functions in the same program can run in different ways. V8 might interpret one function while already having generated machine code for another. It can defer preparing functions that are not needed yet. On a later call, it can reuse code that has already been prepared.