Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Is the syntax of javascript and java the same?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you javascript and java grammar is not the same, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!

The javascript syntax is different from the java syntax. JavaScript is a weakly typed language, which can be uniformly defined by the var keyword instead of specifying the type of the variable, while java is a strongly typed language and must declare the variable with the corresponding type.

The operating environment of this tutorial: windows7 system, javascript1.8.5&&java8 version, Dell G3 computer.

The javascript syntax is different from the java syntax.

The difference between JavaScript and java

* * Features * Java** JavaScript** object-oriented object-oriented programming language is object-based and not completely process-oriented. There are some object-oriented features that run the compiled language and generate intermediate files. The intermediate file bytecode interpretation will not be generated, explain part of it, and then run another part. The cross-platform installation virtual machine runs in the browser, as long as the system has a browser. Data type strongly typed language, different data weak types, the same variable can be assigned to different data types. Types are strictly case-sensitive

JavaScript is a weakly typed language, which can be defined uniformly using the var keyword instead of specifying the type of the variable when declaring the variable. While java is a strongly typed language, variables must be declared with corresponding types; for example, you need to use int and char to define variables of int type and char type, respectively.

JavaScript is a dynamic, weakly typed language, while java is a static, strongly typed language.

Dynamic languages (weakly typed languages) are languages that determine data types at run time. A variable does not need a type declaration before it is used, and usually the type of the variable is the type of the value to which it is assigned.

Static languages (strongly typed languages) are languages that can be determined by the data type of a variable at compile time, and most statically typed languages require that the data type be declared before using the variable.

Strongly typed languages may be slightly inferior to weakly typed languages in speed, but the rigor brought by strongly typed languages can effectively avoid many errors.

For example, if you define an integer variable a, it is impossible for the program to treat an as a string type. Strongly typed definition language is a type-safe language.

But in javaScript, because the constraints are weak, it is easy to make some errors. The simplest example is:

You might expect c to be 201, but in fact it is "2001", an error that never occurs in strongly typed languages. However, it is precisely because JavaScript does not have these constraints that you can easily concatenate numeric and string types.

The above is all the content of the article "are javascript and java grammars the same?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report