Home >Web Front-end >Front-end Q&A >What language is JavaScript?

What language is JavaScript?

青灯夜游
青灯夜游Original
2021-10-19 14:36:093302browse

Javascript is a scripting language that is object- and event-driven, relatively safe, and widely used in client-side web development. It is also a scripting language that is widely used in client-side web development. It is often used for web pages. Add a variety of dynamic functions to provide users with a smoother and more beautiful browsing effect.

What language is JavaScript?

The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, Dell G3 computer.

JavaScript is a scripting language that is object- and event-driven, relatively safe, and widely used in client-side web development. It is also a scripting language that is widely used in client-side web development.

It has been widely used in web application development and is often used to add various dynamic functions to web pages to provide users with smoother and more beautiful browsing effects.

was first used in HTML to add dynamic functions to HTML web pages. It is a prototype-inherited object-oriented dynamic type case-sensitive client script language developed from Netscape's LiveScript. The main purpose is to solve the speed problems left by server-side languages, such as Perl, and respond to various user operations, providing customers with a smoother browsing effect. Because the server needed to verify the data at that time, because the network speed was quite slow, only 28.8kbps, the verification step wasted too much time. So Netscape's browser Navigator added Javascript to provide basic functions of data verification. However, JavaScript can now also be used in web servers such as Node.js.

1. Composition of javascript

A complete JavaScript implementation is composed of the following 3 different parts:

  • ECMAScript: describes the language The syntax and basic objects of Model (BOM for short)): describes the methods and interfaces for interacting with the browser.

  • 2. The basic characteristics of javascript

is an interpreted scripting language (the code is not pre-compiled).

  • Mainly used to add interactive behaviors to HTML pages.

  • Can be directly embedded in HTML pages, but writing it as a separate js file is beneficial to the separation of structure and behavior.

  • 3. Characteristics of JavaScript

    Different from server-side scripting languages, such as PHP and ASP, JavaScript is mainly used as a client-side scripting language to run on the user's browser , does not require server support. Therefore, in the early days, programmers preferred JavaScript to reduce the burden on the server, but at the same time it also brought about another problem: security.
As servers become more powerful, although today's programmers prefer scripts running on the server to ensure security, JavaScript is still popular for its cross-platform and easy-to-use advantages. At the same time, some special functions (such as AJAX) must rely on Javascript to be supported on the client side. With the development of engines such as V8 and frameworks such as Node.js, and their features such as event-driven and asynchronous IO, JavaScript is gradually used to write server-side programs.

4. JavaScript is commonly used to complete the following tasks

1. Embed dynamic text in HTML pages

2. Respond to browser events

3. Read and write HTML elements

4. Verify data before the data is submitted to the server

5. Detect visitor’s browser information

6. Control cookies, including creation and modification Wait

5. How to use Javascript

There are two ways to add Javascript to a web page: direct method and reference method.

1. Direct method

This is the most commonly used method. Most web pages containing Javascript use this method, for example:

<html>
      <head>
      <title>简单的JavaScript Hello World</title>
         <script type="text/javascript">
             document.write("Hello, PHP中文网!");   // 在浏览器视窗内直接显示
             alert("Hello,  PHP中文网!");            //  弹窗显示
             console.log("Hello,  PHP中文网!");      // 在控制台(console)里显示,需要先开启开发工具控制台
         </script>
      </head>
      <body>
   HTML页面内容……
      </body>
   </html>

In this example, we You can see a new tag:

3f1c4e4b6b16bbbd69b2ee476dc4f83a...2cacc6d41bbb37262a98f745aa00fbf0

, and

ee7daa49a56abfe5e8409b7b65ffb3c0

is used to tell the browser that this is Programs written in Javascript need to mobilize the corresponding interpreter for interpretation. (w3c has recommended the use of new standards:

3d1df40a5050db9df35681b82c2528de)Note that when inserting script tags in non-xhtml documents, if they are not referencing external files , a cdata statement should be added to the script to avoid browser parsing errors caused by the greater than and less than operators2. Reference method

If a Javascript source already exists file (usually with js extension), you can use this reference method to improve the utilization of program code. The basic format is as follows:

<script src=“url” type="text/javascript"></script>
The Url is the address of the program file. Likewise, such statements can be placed in the head or any part of the body of an HTML document. If you want to achieve the effect of the example in "Direct Insertion Method", you can first create a Javascript source code file "Script.js" with the following content:
document.write("这是Javascript!采用直接插入的方法!");

在网页中可以这样调用程序:c2b992906fc368867610d61ab35ef6532cacc6d41bbb37262a98f745aa00fbf0

也可以同时在导入文件时制定javascript的版本,例如:3307c2a9026f75b96448a0777eb4891a2cacc6d41bbb37262a98f745aa00fbf0

注意:凡是指定了src属性的script标签里的内容都会被忽略。

【推荐学习:javascript高级教程

The above is the detailed content of What 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