Home >Web Front-end >JS Tutorial >What type of language is javascript?

What type of language is javascript?

青灯夜游
青灯夜游Original
2021-10-15 14:56:386812browse

JavaScript is a literal scripting language, a dynamically typed, weakly typed, prototype-based language. The JS language uses weakly typed variable types and does not impose strict requirements on the data types used; JS is an event-driven scripting language that can respond to user input without going through a Web server. .

What type of language is javascript?

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

JavaScript is a literal scripting language, 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 ("JS" for short) is currently the most popular and widely used client-side scripting language. It is used to add some dynamic effects and interactive functions to web pages and plays a decisive role in the field of web development.

JavaScript has the following characteristics:

  • Interpreted scripting language

    JavaScript is an interpreted scripting language , unlike C, C and other languages ​​that need to be compiled first and then run, code written in JavaScript does not need to be compiled and can be run directly.

  • Object-oriented

    JavaScript is an object-oriented language. Using JavaScript, you can not only create objects, but also operate and use existing objects.

  • Weak type

    JavaScript is a weakly typed programming language that does not have strict requirements on the data type used. For example, you can initialize a variable It is of any type, and the type of this variable can be changed at any time.

  • Dynamics

    JavaScript is an event-driven scripting language that can respond to user input without the help of a Web server. For example, when we visit a web page, when we click on the web page with the mouse or scroll the window, JavaScript can directly respond to these events.

  • Cross-platform

    JavaScript does not depend on the operating system and can run in the browser. Therefore, after a JavaScript script is written, it can be run on any system, as long as the browser on the system supports JavaScript.

Expand knowledge:

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 and disadvantages of statically typed languages

  • The advantages of statically typed languages ​​are that type mismatch errors can be found at compile time, and the editor can help us in advance Avoid errors that may occur during program execution. Secondly, 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.

  • The shortcomings of statically typed languages ​​are that they first force programmers to write programs according to strong contracts and specify data types for each variable. In the final analysis, it is just a means to help us write programs with high reliability. , rather than the purpose of writing a program. After all, the purpose of most people writing a program is to complete the requirements and deliver production. Secondly, 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 and disadvantages of dynamically typed languages

  • The advantage of dynamically typed languages ​​is that 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.

  • The disadvantage of dynamically typed languages ​​is that the type of variables cannot be guaranteed, so type-related errors may occur during the runtime of the program.

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 What type of language is javascript?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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