DEV Community

Kamrul Hasan
Kamrul Hasan

Posted on

How does JavaScript work in browsers? A quick explanation?

We know that JavaScript code runs on the browser. The browser has a browser engine to execute the program. Google chrome has v8 engine, fire-fox has Spider monkey engine, Internet Explorer has Chakra engine.

Image description

Let’s take an example v8 engine of chrome browser. When v8 engine takes the JavaScript code from the js program source files then v8 engine starts parsing the code using “parser”. Then parsing is converted into “Abstract Syntax Tree(AST). After that interpreter converts this Abstract Syntax Tree to “Byte-code” or by using “Just in Time Compiler “optimized machine code”. Just in Time Compiler Increases the performance and code runs faster. In this way JavaScript code works in v8 engine to execute the program.

Top comments (0)