Home >Web Front-end >Front-end Q&A >What are the differences between java and javascript?

What are the differences between java and javascript?

青灯夜游
青灯夜游Original
2021-11-05 11:22:0152564browse

Difference: 1. JavaScript is developed by Netscape Company, and Java is developed by SUN Company; 2. JS is identified by script tag, while Java is identified by Applet; 3. JS is a dynamic type, and Java is static Type; 4. JS variables adopt weak types, Java adopts strong types, etc.

What are the differences between java and javascript?

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

What is the difference between Java and JavaScript? It is said that many people still don’t know. Let’s explain the difference between the two!

The differences between Java and JavaScript:

1. Different uses:

Their most essential The difference is the use: Java is currently widely used in PCs, mobile phones, the Internet, data centers, etc.;

and JavaScript is widely used in Web application development to add various elements to web pages. Dynamic functions provide users with smoother and more beautiful browsing effects.

2. Different origins:

Javascript and Java are different products developed by different companies. Javascript is the scripting language of Netscape;

and Java is a new generation of object-oriented programming language launched by SUN (full name: SUN Microsystems).

3. Different embedding methods:

In HTML documents, the two programming languages ​​have different identifiers. Javascript uses <script></script> to identify ; and Java uses Applet to identify.

4. Different language types:

JavaScript is a dynamically typed language; Java is a statically typed language.

5. The variables used are different:

The variable declaration in JavaScript adopts weak type, that is, the variable does not need to be declared before use, but the interpreter Its data type is checked at runtime. Java uses strongly typed variable checking, that is, all variables must be declared before compilation.

6. Different code formats:

Javascript code is dynamic and can be directly embedded in HTML documents and dynamically loaded. Writing HTML documents is like editing Just as convenient as a text file, its independent file format is *.js. Java is a format that has nothing to do with HTML. It must be loaded like foreign media is referenced in HTML. Its code is saved in a separate document in the form of byte code, and its independent file format is *.class.

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.

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 process text and graphics. Java can directly operate on text and graphics.

The similarities between Java and JavaScript:

Their syntax is very similar to the C language; they are both object-oriented (although the implementation methods are slightly different) ; JavaScript was designed with reference to the naming rules of Java; in short, except that JavaScript looks similar to Java, the language style is very different. JavaScript was designed with reference not to Java, but to languages ​​like Self and Scheme.

Java and JavaScript each have their own strengths and specializations. Java’s stage is in the field of programming, while JavaScript’s advantage is in Web pages, it can do almost everything.

[Recommended learning: javascript advanced tutorial]

The above is the detailed content of What are the differences between java and javascript?. 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