The difference between JavaScript and Java-basic knowledge

Source: Internet
Author: User
The following compare the similarities and differences between the two languages as follows:
1. Object-based and Object-oriented
Java is a real object-oriented language, and even if you are developing a simple program, you must design objects. JavaScript is a scripting language that can be used to create complex software that is unrelated to the network and interacts with the user. It is an object-based (object Based) and event-driven programming language (Driver). As a result, it provides a very rich internal object for designers to use.
2. Interpretation and compilation
The two languages do not perform the same way in their browsers. Java's source code must be compiled before it is passed to the client, so that the client must have an emulator or interpreter on the platform that implements the binding of compiling code independent of a particular platform through a compiler or interpreter.
JavaScript is an interpretative programming language whose source code does not need to be compiled before it is sent to the client, but instead sends the text-formatted character code to the client for interpretation by the browser.
3. Strong variables and weak variables
The variables adopted in the two languages are different. Java uses strongly typed variables to check that all variables must be declared before they are compiled. Such as:
Copy Code code as follows:

Integer x;
String y;
x=1234;
x=4321;

Where the x=1234 description is an integer, the y=4321 description is a string. A variable declaration in JavaScript, using its weak type. That is, the variable does not need to be declared before it is used, but rather the interpreter checks its data type at run time, such as:
Copy Code code as follows:

x=1234;
Y= "4321";

The former indicates that x is a numeric variable, while the latter indicates that Y is a character variable.
4. Code format is not the same
Java is an HTML-independent format that must be loaded through a reference to an external media like HTML, and its code is stored in a separate document as a byte code. JavaScript code is a text character format that can be embedded directly in an HTML document and dynamically loaded. Writing an HTML document is as easy as editing a text file.
5. Different embedding methods
In HTML documents, the identities of the two programming languages are different, JavaScript is used to identify them, and Java is used to identify them.
6. Static and dynamic joint-editing
Java uses a static binder, that is, Java object references must be made at compile time to enable the compiler to implement strong type checking. JavaScript uses a dynamic binder, which is a JavaScript object reference that is checked at run time, and cannot be checked for object references without compilation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.