What is the difference between JavaScript and the Java language _javascript skills

Source: Internet
Author: User

Tell a story: Once Upon a time, there was a man called Netscape (Netscape), who gave birth to a son, was very open, and named his son LiveScript. LiveScript very diligent, help uncle aunt did a lot of work, also to his father made a lot of money. Suddenly one day sun gave birth to a son: Java,java very powerful, popular peak, faint have ascended the throne posture. His father's eyes a turn, think: Java This is to heaven, I have to take the opportunity to send a pen! So he called his son, his mouth a little, revealing a meaningful smile, said, "Son, you see the name of Java cool, after you and his surname." "So, from this JavaScript then appeared in front of everyone, Uncle aunt all behind the talk:" Hey, this will not be the illegitimate child of the next door Java, or call him to help us work to try, "so the JavaScript changed the name, the days are still OK, and then a lot of live. Old Netscape looked at his son, while counting money side happy smile, for his wise complacent "haha, just changed a name, the effect incredibly good, Java really bad." Let the son learn a little bit Java brother, at least in the appearance of dress up, inside still have to flow my old net blood. ”

One sentence summary: Java and JavaScript are two different languages.

1 Language Features:

1.1 Weak type:

JavaScript does not strictly distinguish between data types when declaring variables (var variable name), not as strict as Java (type: variable name). Also say, JavaScript as all sentient beings equal, in his eyes everyone is human, and in the Java eye All sentient beings are different, men, women, Simon what ...

Based on this feature, JavaScript can be written more often than Java, such as the Declaration of functions.

1.2 Dynamic languages:

Java can no longer change after defining the length of an array, but JavaScript does. and Java an array can only be of the same type, but JavaScript can add data of different data types in an array. It can be said that Java compared to the eye, JavaScript is more flexible.

1.3 Scripting languages:

Java and other background languages are compiled and executed, but JavaScript is executed by the side of the compilation.

2 data types

2.1 Basic data types:

Java has eight major data types: Byte,short,int,long,float,double,char,boolean. It feels like JavaScript has sorted the top three original types: Number,string,boolean. There are two other special original types: null and undefined.

2.2 Variables

Java: Data type variable name = value;

Javascript:var variable name = value; array

Java:

Type [] Array name =new type [quantity];

Type [] Array name =new type []{element 1, element 2 ...} ;

Javascript:

var array name =[];

var array name =new array ();

3 functions:

Java: Return value type function name (type parameter 1, type parameter 2 ...) ){}

javascript:function function name (parameter 1, parameter 2 ...) ){}

The above is a small set of JavaScript and the Java language of the similarities and differences (i), I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Related Article

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.