Home > Web Front-end > JS Tutorial > body text

JavaScript tutorial: Getting to know JavaScript for the first time

黄舟
Release: 2016-12-22 15:52:15
Original
1133 people have browsed it

What is JavaScript?

JavaScript is an object- and event-driven scripting language with security features. The purpose of using it is to realize linking multiple objects in a Web page together with HTML hypertext markup language and Java script language (Java applet) to interact with Web clients. This allows you to develop client applications, etc. It is implemented in the standard HTML language by embedding or calling in. Its appearance makes up for the shortcomings of the HTML language. It is a compromise between Java and HTML and has the following basic features:

Scripting language

JavaScript is a scripting language that uses small program segments to implement programming. Like other scripting languages, JavaScript is an interpreted language, which provides an easy development process.

Its basic structural form is very similar to C, C++, VB, and Delphi. But it does not need to be compiled first like these languages, but is interpreted line by line during the running of the program. It is combined with HTML markup to make it easier for users to use.

Object-based language

JavaScript is an object-based language and can be regarded as an object-oriented language. This means that it can use objects it has already created. Therefore, much functionality can come from the interaction of methods of objects in a scripting environment with scripts.

Simplicity

The simplicity of JavaScript is mainly reflected in: First of all, it is a simple and compact design based on Java's basic statements and control flow, which is a very good transition for learning Java. Secondly, its variable type is weakly typed and does not use strict data types.

Security

JavaScript is a security language. It does not allow access to the local hard drive, cannot store data on the server, does not allow modification and deletion of network documents, and can only browse information through a browser. or dynamic interaction. This effectively prevents data loss.

Dynamics

JavaScript is dynamic, it can respond directly to user or customer input without going through the Web service program. It responds to users in an event-driven manner. The so-called event-driven refers to the action generated by performing a certain operation on the home page, which is called an "event". For example, pressing the mouse, moving the window, selecting the menu, etc. can be regarded as events. When an event occurs, a corresponding event response may be triggered.

Cross-platformability

JavaScript depends on the browser itself and has nothing to do with the operating environment. As long as the computer can run the browser and the browser supports JavaScript, it can be executed correctly. Thus realizing the dream of "write once and travel all over the world".

In fact, the most outstanding thing about JavaScript is that it can do a lot of things with a small program. There is no need for a high-performance computer. The software only requires a word processing software and a browser. There is no need for a WEB server channel. Everything can be done through your own computer.

In summary, JavaScript is a new description language that can be clamped into HTML files. The JavaScript language can respond to user demand events (such as form input) without using any network to transmit data back and forth. Therefore, when a user inputs a piece of data, it does not need to be passed to the server. ) processing and then passing it back, which can be directly processed by the client application.


Writing the first JavaScript program

Below we use an example to write the first JavaScript program. It explains how JavaScript scripts are embedded into HTML documents.

For example:

<html>
<head>
<meta charset="utf-8">
<Script Language ="JavaScript">
// JavaScript Appears here.
alert("这是第一个 JavaScript 例子!");
alert("欢迎你进入 JavaScript 世界!");
alert("今后我们将共同学习 JavaScript 知识!");
</Script>
</head>
</html>
Copy after login

Program running output:

JavaScript tutorial: Getting to know JavaScript for the first time


The above is the content of the JavaScript tutorial for getting to know JavaScript for the first time. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


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