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

Whether javascript is a dynamic weak language

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

Share

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

This article mainly explains "whether javascript is a dynamic weak language". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "whether javascript is a dynamic weak language".

Javascript is a dynamic weak language, it is a literal scripting language, it is a dynamically typed, weakly typed, prototype-based language. In javascript, data types can be ignored, and when you assign a value to a variable, you don't need to consider its type; you don't have a type until the variable is assigned a value.

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

What are statically typed languages and dynamically typed languages?

Programming languages can be divided into two categories according to data types, one is statically typed language, the other is dynamically typed language.

A statically typed language determines the type of a variable at compile time, while a dynamically typed language does not have a type until the variable is assigned a value when the program is running.

In JavaScript, when assigning a value to a variable, you don't need to consider its type, so JavaScript is a typical dynamically typed language.

Advantages of dynamically typed languages:

Less code is written and looks more concise, so programmers can focus more on business logic. Although not distinguishing types can make a program difficult to understand in some cases, on the whole, the less code and the more focused on logical expression, the more helpful it is to read the program.

What are strongly typed and weakly typed languages?

1), strongly typed language:

The language that forces the definition of the data type. That is, once a variable is assigned a data type, it will always be that data type if it is not cast. For example: if you define an integer variable a, it is impossible for the program to treat an as a string type at all. Strongly typed definition language is a type-safe language.

2), weakly typed languages:

A language in which data types can be ignored. In contrast to strongly typed definition languages, a variable can assign values of different data types.

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

The embodiment of javascript weak type

The general rule is that the stronger the constraint, the less likely it is to make mistakes, but the more troublesome it is to write programs. In JavaScript, this kind of error is easy to occur because the constraints are weak: the simplest example: var a = 200

Var b = "1"; var c = a + b

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.

Thank you for your reading. the above is the content of "whether javascript is a dynamic weak language". After the study of this article, I believe you have a deeper understanding of whether javascript is a dynamic weak language. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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