In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
How the javascript engine works, in view of this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
How the javascript engine works
What is the JavaScript parsing engine?
To put it simply, a JavaScript parsing engine is a program that can "read" JavaScript code and accurately give the results of its execution. For example, when you write var a = 1 + 1; what the JavaScript engine does is understand (parse) your code and change the value of a to 2.
Anyone who has studied the principles of compilation knows that for static languages (such as Java, C++, C), the one that handles these things is called Compiler, and accordingly for dynamic languages such as JavaScript, it is called Interpreter. The difference between the two can be summed up in one sentence: the compiler compiles the source code into another type of code (such as machine code, or bytecode), while the interpreter parses the code directly and outputs the results of the code. For example, firebug's console is a JavaScript interpreter.
However, it is difficult to define whether the JavaScript engine is an interpreter or a compiler, because, for example, like V8 (Chrome's JS engine), in order to improve the performance of JS, it will compile JS into native machine code (native machine code) before running, and then execute machine code (which is much faster). I believe you must be familiar with JIT (Just In Time Compilation).
Personally, I don't think it's necessary to put too much emphasis on what the JavaScript parsing engine is, and I personally think it's fine to know what it does. As for how the compiler or interpreter understands the code, just find out the textbook of the university compilation course.
It is also emphasized here that the JavaScript engine itself is also a program, written by code. For example, V8 is written in CCompact +.
What is the relationship between JavaScript parsing engine and ECMAScript?
The JavaScript engine is a program, and the JavaScript code we write is also a program. How to make the program understand the program? This requires the definition of rules. For example, var a = 1 + 1, which is mentioned earlier, says:
Var on the left represents this is the declaration, which declares the variable a.
The + on the right means to add 1 and 1.
The equal sign in the middle indicates that this is an assignment statement.
The last semicolon indicates that the sentence is over.
These are the rules, and with it there is a standard by which the JavaScript engine can parse JavaScript code. So the ECMAScript here defines these rules. The document ECMAScript 262 defines a complete set of standards for the language JavaScript. These include:
Var,if,else,break,continue is the key word of JavaScript.
Abstract,int,long and so on are reserved words of JavaScript.
How is it a number, how is it a string, etc.
Defines the operator (+, -, >
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.