Is javascript based on java?

青灯夜游
Release: 2022-10-18 16:03:50
Original
4093 people have browsed it

Javascript is not based on Java, they are two completely different language architectures. Java is a language between interpreted and compiled languages. Before being passed to the client for execution, the source code of Java must be compiled and compiled independently of a specific platform through the interpreter on the corresponding platform. The constraints of the code; JavaScript is an interpreted programming language, and its source code does not need to be compiled before being sent to the client for execution. Instead, character codes in text format are sent to the client for interpretation and execution by the browser.

Is javascript based on java?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

javascript is not based on java. Although Java and javascript are both programming languages, they are two completely different language architectures.

Java is a new generation of object-oriented programming language and a programming language launched by SUN Company, which is particularly suitable for Internet application development. It is an interpreted language with syntax rules similar to C.

JavaScript is a product of Netscape. Its purpose is to extend the functions of Netscape Navigator and develop an object-based and event-driven interpreted language that can be embedded in Web pages; it is a compliance with the ECMA 262 language specification. A realization.

The reason why the letters in the shapes of java and javascript are very similar

It is generally believed that the reason why Netscape named LiveScript JavaScript at that time was because Java was the most popular programming at the time. Language, with the name "Java" helping the spread of this new language.

To put it bluntly, isn't this a typical hot spot nowadays?

Many Java programmers want to learn a scripting language. When they see how it is so similar to Java, they feel very familiar with it, so they might as well learn it.

JavaScrip has taken advantage of Java's hot spots, which has greatly helped its development. Of course, its language itself is also excellent, and it has slowly been recognized by the public.

The similarities between Java and JavaScript:

  • Their syntax is very similar to the C language ;

  • They are all object-oriented (although the implementation methods are slightly different);

  • JavaScript was designed with reference to Java’s naming Rules;

The difference between javascript and java

1. JavaScript and Java are produced by different companies different products developed.

Javascript is a product of Netscape. Its purpose is to extend the functions of Netscape Navigator and develop an object-based and event-driven interpreted language that can be embedded in Web pages;

Java is a new generation of object-oriented programming language launched by SUN Microsystems, which is particularly suitable for Internet application development. In fact, the original name of javascript was not javascript, but LiveScript. The "Java" in the name was authorized by SUN Microsystems.

2. Java and JavaScript are essentially different

Javascript is object-based, a scripting language, and an object- and event-driven programming language. , thus it itself provides a very rich set of internal objects for designers to use. Java is object-oriented, that is, Java is a true object-oriented language. Even when developing simple programs, objects must be designed.

3. JavaScript and Java are executed in different ways in the browser

javascript is an interpreted programming language, and its source code is sent to the client It does not need to be compiled before execution, but the character code in text format is sent to the client, that is, the javascript statement itself is downloaded along with the Web page and interpreted and executed by the browser.

The Java source code must be compiled before being passed to the client for execution. Therefore, the client must have an emulator or interpreter on the corresponding platform. It can be independent of the compiler or interpreter. Compile code for a specific platform.

4. Java mainly runs on the server side; javascript mainly runs on the client browser.

5. The variables used by javascript and Java are different. Similarly, variable declarations in JavaScript use weak types, that is, variables do not need to be declared before use, but the interpreter checks their data type at runtime. Java uses strong type variable checking, that is, all variables must be declared before compilation.

6. Different binding methods

Javascript uses dynamic binding, that is, JavaScript object references are checked at runtime. Java uses static binding, that is, Java object references must be made at compile time so that the compiler can implement strong type checking.

7,

javascript does not directly operate on text and graphics. It works together with HTML element combinations in Web pages, but it can control the browser and let the browser directly operate on text. and graphics processing. Java can directly operate on text and graphics.

8.

Java’s grammatical rules are much stricter than JavaScript, and its functions are much more powerful.

9, Java language code is a language that has nothing to do with HTML; JavaScript language code is a text character format that can be directly embedded in HTML documents and can be loaded dynamically.

10. The uses of the two are also different

java is widely used in personal PCs, data centers, game consoles, scientific supercomputers, mobile phones and the Internet, etc. .

The purpose of Javascript is:

1). Embed dynamic text in HTML pages;

2).Respond to browser events;

3).Read and write HTML elements;

4).Verify data before the data is submitted to the server;

5).Detect the visitor’s browser information;

6). Control cookies, including creation and modification.

Explanation:

In addition to looking more similar to Java, JavaScript has a very different language style. JavaScript was designed with reference not to Java, but to languages ​​like Self and Scheme.

【Related recommendations: javascript video tutorial, programming video

The above is the detailed content of Is javascript based on java?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template