Differences between JavaScript and Java

zhaozj2021-02-11  180

Although JavaScript is closely related to Java, it is a different product developed by two companies. Java is a new generation of object-oriented programming languages ​​launched by Sun, especially suitable for Internet applications; while JavaScript is a product of Netscape, its purpose is to expand Netscape Navigator features, and one of the developments can be embedded in the web page. Object and event-driven explanatory language, its predecessor is Live Script; and Java's predecessor is Oak language. The following is a comparison of the difference between the two languages: 1. Object and object-oriented Java are a true object-oriented language, even if it is a simple program, it is necessary to design an object. JavaScript is a basic scripting language that can be used to make complex software interacting with the network. It is a programming language based on Object Based and event driver. Therefore, it itself provides a very rich internal object for designers. 2. Interpretation and compiling two languages ​​are different in its browser. Java's source code must be compiled before passing to the client, so it must have an emulator or interpreter on the client, which can achieve independent platform compile code through a compiler or interpreter. Chain. JavaScript is an interpretative programming language that does not need to be compiled before sending to the client, but to send the character code of the text format to the customer's interpretation. 3. The variables taken by strong variables and weak variables are different. Java adopts strong type variable check, that is, all variables must be declared before compiling. Such as: integer x; string y; x = 1234; x = 4321; where x = 1234 illustrates an integer, y = 4321 Description is a string. The variable declarations in JavaScript use their 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 explains X is its numerical variable, and the latter illustrates Y as character type variable. 4. The code format is different. Java is a format that is unrelated to HTML. It must be loaded by reference to foreign media like HTML, and its code is saved in a separate document in the form of byte code. JavaScript's code is a text character format that can be embedded directly into the HTML document and can be loaded. Writing an HTML document is as convenient to edit text files. 5. Embedded mode is different in the HTML document, the identity of the two programming languages, JavaScript uses