Home > Web Front-end > JS Tutorial > How to understand that javascript is a dynamic language

How to understand that javascript is a dynamic language

醉折花枝作酒筹
Release: 2023-01-07 11:43:49
Original
2749 people have browsed it

The variable type of dynamically typed language will not have a certain type until the variable is assigned a certain value when the program is running. Javascript is an interpreted language, not a compiled language, it cannot be compiled into a binary file.

How to understand that javascript is a dynamic language

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

JavaScript is a dynamically typed, weakly typed, prototype-based language. Its interpreter is called the JavaScript engine, which is part of the browser and is widely used in client-side scripting languages. It was first used on HTML web pages to add dynamic functions to HTML web pages.

Javascript is an interpreted language, not a compiled language. It cannot be compiled into a binary file.

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

The type of variables in statically typed languages ​​is determined at compile time, while the variable types in dynamically typed languages ​​will not have a certain type until the variable is assigned a certain value when the program is running.

Advantages of statically typed languages:

1. Type mismatch errors can be found during compilation. The editor can help us avoid some errors that may occur during program running.

2. If the data type is clearly specified in the program, the compiler can also perform some optimization work on the program based on this information to improve the execution speed of the program.

Disadvantages of statically typed languages:

1. Force programmers to write programs according to strong contracts and specify data types for each variable. In the final analysis, it is just a way to assist us in writing highly reliable programs. Means, not the purpose of writing programs. After all, the purpose of most people writing programs is to complete the requirements and deliver production.

2. Type declarations will also add more code. During the program writing process, these details will distract the programmer's energy from thinking about business logic.

Advantages of dynamically typed languages:

The amount of code written is less and it looks more concise. Programmers can focus more on business logic. Although not distinguishing between types can make the program difficult to understand in some cases, overall, the smaller the amount of code and the more focused on logical expression, the more helpful it is for reading the program.

Disadvantages of dynamically typed languages:

The type of variables cannot be guaranteed, so type-related errors may occur during the runtime of the program. It's like buying a pack of beef chili strips at the store, but you don't know whether they taste like beef until you actually eat them.

Javascript is a dynamic language. In JavaScript, when assigning a value to a variable, there is no need to consider its type. Therefore, JavaScript is a typical dynamically typed language.

The tolerance of dynamically typed languages ​​to variable types brings great flexibility to actual coding. Without type checking, we can try to call any method on any object, regardless of whether it was designed to have that method.

[Recommended learning: javascript advanced tutorial]

The above is the detailed content of How to understand that javascript is a dynamic language. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template