Front-end interview-the difference between 2-java and JavaScript in difficult questions

Source: Internet
Author: User

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

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.