JS - s50600822/Notes GitHub Wiki

JavaScript is executed in the following manner:

Parsing: The JavaScript engine first parses the JavaScript code to understand the syntax and structure of the code. This process is done by the parser, which converts the code into an Abstract Syntax Tree (AST). The AST is a tree-like data structure that represents the structure of the code.

Compilation: Once the code is parsed, the engine compiles the code into executable code. During the compilation process, the engine optimizes the code to improve performance. The optimization includes removing dead code, inlining functions, and optimizing loops.

Execution: The compiled code is then executed by the JavaScript engine. The engine runs the code line by line, and executes each statement in the order they appear. The engine also manages the memory used by the code, and performs garbage collection to free up memory that is no longer in use.

It is important to note that different JavaScript engines may execute code differently, as they may use different parsing and compilation techniques, as well as optimizations.

some of the popular JavaScript engines:

Engine Name Description
V8 An open-source JavaScript engine developed by Google for use in Chrome and Node.js.
SpiderMonkey The original JavaScript engine developed by Brendan Eich for the Netscape Navigator web browser.
JavaScriptCore A JavaScript engine developed by Apple for use in Safari and other WebKit-based browsers.
Chakra A JavaScript engine developed by Microsoft for use in Microsoft Edge and Internet Explorer.
Rhino A JavaScript engine written in Java that can run standalone or embedded in Java applications.
Nashorn A JavaScript engine developed by Oracle that is included in the Java SE Development Kit (JDK).
GraalVM A polyglot virtual machine that supports multiple languages, including JavaScript, developed by Oracle Labs.
QuickJS An embeddable JavaScript engine with a small footprint, developed by Fabrice Bellard.
Duktape An embeddable JavaScript engine with a focus on portability and compactness, developed by Duktape project.