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;
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";
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 2934a685527f5cd6bcb20a3dc28499e1...bedae1ad67868425befe4a2056d27ff6 Identification, while Java uses 082dedeb30a00d0e6e2cdb74a392fac3...0f47783e45a827c89a02ecd1506bec99 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!