Home >Java >Javagetting Started >The difference between javascript and java

The difference between javascript and java

王林
王林Original
2019-11-13 16:00:1214302browse

The difference between javascript and java

The difference between java and javascript:

1. Java is an object-oriented language, and JavaScript is a scripting language based on objects and event-driven languages.

2. Java source code must be compiled before execution, but JavaScript code does not need to be, and can be directly interpreted and executed by the browser.

3. Strongly typed languages ​​and weakly typed languages. Java is a strongly typed language, and variables must first be declared in the program before using them; Java will check the type of the variable during compilation. JavaScript is a weakly typed language with looser syntax and rules.

4. The data types are different. There are 8 data types in Java, namely: byte type, short type, long type, int type, float type, double type, char type and Boolean type. There are only five data types in JavaScript, namely: number type, string type and Boolean type. NAN and Undefined reference data types include Array, Object, and Function.

5. The execution environment is different. Java applications can run in any virtual machine (JVM) or web browser and use more memory while executing. And JavaScript code only runs on the browser because JavaScript was developed only for the browser. It requires very little memory to run, so it can be used in web pages.

6. Different positioning. Java is a completely object-oriented OOP programming language. If we want to use Java to write things, we must first design the objects; JavaScript is an object-based OOP scripting language, which provides developers with many internal objects. , to be simpler and more time-saving.

7. Different binding methods. Java uses static binding and is a static type language. Java object references must be made at compile time, and the compiler needs to implement strong type checking. JavaScript is different. It uses dynamic binding and is a dynamically typed language. Its object references can be checked at runtime.

8. Concurrency methods are different. Java has a thread-based approach to concurrency. And Javascript has event-based concurrency approach.

Recommended tutorial: Java tutorial

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