After a variety of references, combined with their own knowledge, summed up the difference between Java and JavaScript. You are welcome to comment!
First, the relationship
Although Java and JavaScript are somewhat similar in name and syntax, and have some connections, JavaScript syntax originates from Java. But in fact they are different products developed by two companies, two completely different programming languages. Java is a new generation of object-oriented programming language from Sun, which is particularly suitable for Internet application development, formerly the Oak language, and JavaScript is the product of Netscape Corporation, which is designed to extend Netscape Navigator functionality , and developed an object-based and event-driven interpretive language that can be embedded in Web pages, formerly known as Live Script.
Second, the procedure operation process
Java is compiled to execute, the source file must be compiled to generate intermediate files, the final execution of the intermediate files, so need to install the JRE or JDK (including the JRE), and environment configuration. While JavaScript is interpreted to perform without generating intermediate files, "read a sentence, execute a sentence", the execution can generally be done in three ways:
1. The general browser comes with the JS interpreter, which can be used directly by the browser;
2. Special interpreter software can be installed node. js, executing the. js file;
3. Executed with the Web page, using the <script> tag, you can put JavaScript statements into the tag, or you can introduce the external. js file via tags.
Third, the data type
Java is a strongly typed language, and when it comes to data, the declaration must specify the data type, for example: int a = 10;
While JavaScript is a weakly typed language, when declaring a data, you only need to use the keyword Var, such as: var a = 10; The specific data types are identified based on what the variables store.
Iv. implementation of inheritance
Java is a truly object-oriented language, and inheritance is implemented through classes, whereas JavaScript is an object-based language, and inheritance is implemented through the way of prototype objects.
V. Implementation of overloading
Overloading: Methods, depending on the parameter list passed in, perform different tasks.
Java is syntactically capable of overloading, while JavaScript does not support overloading, but it can be implemented by arguments object emulation.
Front-end interview-the difference between 2-java and JavaScript in difficult questions