Home > Java > JavaBase > body text

What is the difference between js and java?

青灯夜游
Release: 2019-12-26 17:31:24
Original
8526 people have browsed it

What is the difference between js and java?

Java is an object-oriented programming language. It not only absorbs the various advantages of the C language, but also abandons the concepts such as multiple inheritance and pointers that are difficult to understand in C. Therefore, the Java language has Powerful and easy to use.

js (JavaScript) is a literal scripting language, a dynamically typed, weakly typed, prototype-based language. Its interpreter is called the JavaScript engine, which is part of the browser and is widely used in client-side scripting languages. It was first used on HTML web pages to add dynamic functions to HTML web pages.

Object-based and object-oriented

Java is a true object-oriented language. Even to develop simple programs, objects must be designed.

JavaScript is a scripting language that can be used to create complex software that has nothing to do with the network and interacts with users. It is an Object Based and Event Driver programming language. Therefore it itself provides a very rich set of internal objects for designers to use.

Different data types

● Java data types include: int, double, char, Boolean, etc.

●  Js data types include: number, string, Boolean, etc.

Different binding methods

● Static binding used by Java.

● Js uses dynamic binding.

Different uses

● Java is widely used on PCs, mobile phones, the Internet, data centers, etc.

● Js is mainly used to embed text into HTML pages, read and write HTML, control cookies, etc.

Strong variables and weak variables

Two The variables used by each language are different.

Java uses strong type variable checking, that is, all variables must be declared before compilation. For example:

  Integer x; 
  String y;
  x=1234;
  x=4321;
Copy after login

X=1234 indicates an integer, and Y=4321 indicates a string.

Variable declaration in JavaScript adopts its weak type. That is, the variable does not need to be declared before use, but the interpreter checks its data type at runtime, such as:

  x=1234;
  y="4321";
Copy after login

The former indicates that x is a numeric variable, while the latter indicates that y is a character variable. variable.

The code format is different

Java is a format that has nothing to do with HTML. It must be loaded like foreign media is quoted in HTML. Its code is The form of byte code is stored in a separate document.

JavaScript code is a text character format that can be directly embedded in HTML documents and can be loaded dynamically. Writing HTML documents is as easy as editing text files.

The embedding methods are different

In the HTML document, the two programming languages ​​have different identifiers. JavaScript uses <Script>...</Script> Identification, while Java uses ... for identification.

Recommended learning: Java video tutorial

The above is the detailed content of What is the difference between js and 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