Home  >  Article  >  Web Front-end  >  From basics to proficiency-javascript language

From basics to proficiency-javascript language

零下一度
零下一度Original
2017-06-26 11:50:371060browse

Javascript is an interpreted programming language with object-oriented capabilities. It is a client-side scripting language that is object- and time-driven and relatively secure. Because it does not need to run in a language environment, it only needs a browser that supports it. Its main purpose is to verify the data sent to the server, increase web interaction, and enhance user experience.

The difference between interpreted language and compiled language

Interpreted language: This is the program that is compiled during operation Compiled into machine language.

        Compiled language : This type of language has a compilation process when running the program, but the program is not compiled into machine language, but into bytecode. For example, when the Java language is running, the JVM translates the bytecode into machine language. JVM is a java virtual machine, which is a fictitious computer.

But the efficiency of compilation of interpreted languages ​​is slower than that of compiled languages. JavaScript is an interpreted language. When it parses the program on the browser, js uses its own interpretation engine on the browser. javascript v8 engine. When the browser core compiles js into a view, it needs to go through three stages: "lexical analysis", "grammatical analysis" and "code generation". This is an obvious characteristic of compiled languages. For details, see Chapter 2 of "Rhinoceros Book" and "JavaScript You Don't Know" Chapter 1.

java code is executed by JVM

javascript is executed by javascript interpreter

Each Browsers are different and are generally included in the kernel of each browser.

The browser kernel generally contains two engines: Page layout engine and JS engine

IE uses its own Trident kernel

FireFox is the Gecko kernel

Opera is the Presto kernel

Safari uses the Webkit kernel

Chrome is Google’s own javascript V8 engine and its page layout uses the Webkit kernel

JavaScript is a scripting language, and scripting language is also an interpreted language. Scripting language does not need to be compiled, it is directly interpreted Just use the tool to explain. Judging from the argument that JavaScript is a compiled language just now, JavaScript is also a compiled language. It cannot be generalized as a scripting language. The way to understand scripting languages ​​is simple.

Write a program called xxx.exe. Click .exe to open a file with the extension .aa. Then you have specified rules for writing .aa files. This is what the script does and its relationship. Use instructions to let the program execute in order.

Understanding the relationship and principles of javascript in the browser kernel

Principles of browser parsing and rendering pages:

Talking about this I must mention the familiar webkit, the rendering engine of Google Chrome. The rendering engines in other browsers are not the same, and the core engines of each browser are inconsistent, so now we have to deal with a lot of compatibility issues with major browsers in the process of writing HTML code to layout the page structure. .

The most important and core part of the browser is the interpretation engine, which is the browser kernel. A web page needs to use two engines to work properly: a rendering engine and an interpretation engine. Various ways of writing compatibility are targeted at these browser kernel engines. So what are the current mainstream browser cores?

# The four mainstream browsers on the market

# ie

The browser kernel used by Trident (four The processing speed is the slowest among large cores)

Due to the share of the window market, IE browser has used its position to create a situation where the Trident kernel is the only one. Because of this situation, Microsoft has not dealt with it for a long time. Trident has been updated. Trident has been out of touch with W3C standards and has a large number of bugs and security issues that cannot be solved, which directly led to the rise of the FireFox browser. However, due to its market share, the most troublesome compatibility issue for front-end development engineers now is for some lower versions of IE.

FireFox

The browser kernel used is Gecko

Open source code, fast operation and processing speed. Open source things are always easy to be welcomed by the majority of apes! And there are many browsers that use Gecko, usually used in some foreign browsers. Don’t think too much about it domestically!

Opera

## This browser kernel is Presto

The most fierce brutal interpretation engine! Web page layout engine. It has been highly optimized to increase the rendering speed. To put it simply, it is all about efficiency and speed. But there are gains and losses, and speed is gained at the expense of compatibility. Needless to say, it is the fastest parsing javascript among all browser cores. But now, because the front-end is developing so fast, user experience is the priority in everything, and compatibility cannot be sacrificed for speed. Opera stopped presto and switched to Google's Blink kernel.

Chrome

The browser kernel used is webkit rendering engine javascript v8 interpretation engine

Everything that should be said has been explained above. No further explanation here. This is also the core of the Chrome browser, a browser that many people have begun to learn about front-end and front-end engineers prefer. It is Apple's own core.

# Shell browser :

Use IE kernel instead of IE browser. This kind of browser is called "shell browser". The reason for this is that Trident is an open kernel, so a large number of such shell browsers have appeared in the domestic market. For example, 360, Tencent TT, Cheetah, and Aoyou use dual-core or even multi-core methods. One of them is a Trident core, and other cores are added to the others. Domestic browser manufacturers generally divide this situation into two types, "high-speed browsing mode" and "compatible browsing mode" for users to switch back and forth. Among them, IE kernel Trident is "compatible browsing mode" because domestic manufacturers The applied IE kernel version is not very high and cannot keep up with Trident's iterative update speed. The lower version of the IE kernel is too small and convenient for users to download. Therefore, it has been widely bundled, installed and used since the beginning of development. Until now, there will be certain security problems.

As rated by many issues above, solve and cognition step by step. We know what an interpreted language is and what a compiled language is. I got to know the browser kernel through interpreted languages. Some of the differences between them are closely related to the process of writing code. In the process of learning the web front-end or in the process of constantly improving yourself, understanding and knowing JavaScript must be the most important. In the development process of JavaScript, perhaps many friends thought before that it was necessary to study JavaScript with concentration? From now on, if someone consults you and wants to learn a language or master a new language, you need to recommend JavaScript to him. It must be JavaScript. From the emergence of jQuery, which first drove the development of javascript, to html5, which made javascript truly accessible to people, and now to nodejs. It completely subverts most people's previous views on JavaScript. The emergence of these new frameworks gives JavaScript true unlimited potential!

HTML5 is the advanced content of JavaScript. But some optimizations have been done and some new tags have been added. The new tags are not difficult to understand and easy to use. Why are they defined as the basic part of html? The real power of HTML5 is that you can create tags through JavaScript and use the two characteristics of the kernel to interpret and render respectively. Canvas is also well-known because of its powerful functions, including animation, special effects, games, and data. visualization. All require javascript and background support to have their effect. All thanks to javascript. webgl supports HTML5 canvas drawing 3D image effects. The geographical location expenditure of html5 is displayed in the browser through LBS applications and so on. The connection between javascript and document database has achieved too many impossibilities. The ECMAscript version is constantly iteratively updated, and there are too many js frameworks based on it, such as vuejs, angularjs, reactjs...

The above is the detailed content of From basics to proficiency-javascript language. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn