JavaScript Getting Started 1 --------------- Jilin University CAE Campus Fee Forum Faith 2008

xiaoxiao2021-03-06  54

The Internet era has created our new work and lifestyle, its interconnect, openness, and shared information, breaking the heavy barriers of traditional information communication methods, bringing us new opportunities. With the arrival of computers and information, the footsteps of human society gradually increase, every day has new things, and every day has created a miracle. With the sharpness of the Internet technology, all walks of life are in the industry of joining the Internet. Regardless of management, the Internet can bring unlimited vitality from a business perspective. With Internet, you can achieve a "unified harmony" to achieve regional, collective and even personal connections. So how do you join your or company's information resources to the WWW server, is a major concern for users. Using hyperlink technology (hypertext and super medium) is the easiest, fastest way to achieve this goal. Specifically, the support environment of this means is true, that is, HTML hypertext identification language. Through them, they can make the required web page.

By hyper text and hyper media (Hyper Media) Binding hyperlinks, various information is organized into a network structure (web), which constitutes a network document (Document) to implement "roaming on the Internet" ". The retrieval of multimedia information such as text, table, sound, image, and animation can be realized by the description of the HTML symbol.

However, there is a certain defect in this hyperlink technology, that is, it can only provide a static information resource, lack of dynamic client interactions with the server side. Although a certain interaction can be implemented via the CGI (Common Gateway Interface General Gateway), it is more complicated because the method is programmed, and the development of Internet technology is hampered for a period of time. The emergence of JavaScript has brought a line of vitality on Internet users. It can be said that the emergence of JavaScript is the demand of the times and is the current era of today's information.

The emergence of JavaScript, it can make information and users just a relationship between display and browsing, but realize a real-time, dynamic, canable expressive ability. This will provide dynamic real-time information based on CGI static HTML pages, and replaces the web page of the client operation. The JavaScript script is the language that satisfies this need. It welcomes a wide range of users. It is a more excellent in many scripting languages, which effectively implements the blueprint for network computing and network computers with WWW. The non-condensing Java family will occupy the dominant position of the Internet network. Therefore, mastering the JavaScript scripting language programming method as soon as possible is the increasingly concern of our customers.

First, what is JavaScript

JavaScript is a scripting language based on object (Object) and event driven and has a safe performance. Using its purpose is to link multiple objects in a web page together with the HTML hypercraft markup language, Java scripting language (Java applet) to link multiple objects in a web page, interact with the web client. Thus, you can develop a client application. It is implemented by embedding or tuning in a standard HTML language. Its appearance makes up the shortcomings of the HTML language, which is the choice of Java and HTML compromise, with the following basic features:

1. Yes a script writing language

JavaScript is a scripting language that implements programming in a small program. Like other scripting languages, JavaScript is also an explanatory language that provides an easy development process.

Its basic structure is very similar to C, C , VB, Delphi. But it is not as these languages, it needs to be compiled first, but is explained in progress during the operation of the program. It combines with the HTML identifier to facilitate the user's use operation.

2. Object-based language.

JavaScript is an object-based language that can be seen as an object-oriented. This means that it can use the objects you have created. Therefore, many functions can come from the method of objects in the script environment and the interaction of scripts. Simplicity

The simplicity of JavaScript is mainly reflected in: First of all, it is a simple and compact design based on Java basic statements and control flow, so that Java is a very good transition. Second, its variable type is a weak type and does not use a strict data type.

safety

JavaScript is a security language that is not allowed to access the local hard disk, and the data cannot be stored on the server, which is not allowed to modify and delete the network document, and only information browsing or dynamically interact with the browser. This effectively prevents loss of data.

Dynamic

JavaScript is dynamic, which can respond directly to the user or customer input, without the need to pass through the web service. It responds to the user, which is carried out in an event-driven manner. The so-called event driver is to refer to the action generated by some operation in the home page, called "event". For example, you can be considered as an event such as pressing mouse, moving window, and selecting menu. When the event occurs, it may cause the corresponding event response.

3. Cross-platform

JavaScript is dependent on the browser itself, has nothing to do with the operating environment, as long as you can run your browser, and support JavaScript browser. Thus, "writing once, walking through the world" dream.

In fact, JavaSCR must have high-performance computers, software only one word processing software and a browser, no Web server channels, the most outstanding thing through ourselves is to do a lot of things with a small program. There is no computer to complete all things.

Comprehensive JavaScript is a new description language that can be clamped into the HTML file. The JavaScript language can respond to the user's demand event (such as input), without any network to transfer information, so when a user enters a material, it does not have to pass to the servo end (Server ) The process of processing, retrnating, and can directly be processed by the client (client).

JavaScript and Java are very similar, but it is not the same! Java is a multi-complex language than JavaScript, while JavaScript is quite easy to understand. JavaScript creators can not focus on program techniques, so many Java features are not supported in Java Script.

Second, the difference between JavaScript and Java

Although JavaScript has a close relationship with Java, it is a different two products developed by two companies. Java is a new generation of object-oriented programming languages ​​launched by Sun, especially suitable for Internet applications; while JavaScript is a product of Netscape, its purpose is to expand Netscape Navigator features, and one of the developments can be embedded in the web page. Object and event-driven explanatory language, its predecessor is Live Script; and Java's predecessor is Oak language. The following is a comparison of the difference between the two languages:

Object-oriented object

Java is a real object-oriented language, even if it is a simple program, it is necessary to design an object.

JavaScript is a basic scripting language that can be used to make complex software interacting with the network. It is a programming language based on Object Based and event driver. Therefore, it itself provides a very rich internal object for designers.

2. Explain and compile

The two languages ​​are different in its browser. Java's source code must be compiled before passing to the client, so it must have an emulator or interpreter on the client, which can achieve independent platform compile code through a compiler or interpreter. Chain. JavaScript is an interpretative programming language that does not need to be compiled before sending to the client, but to send the character code of the text format to the customer's interpretation.

Strong variable and weak variable

The variables taken by both languages ​​are different.

Java adopts strong type variable check, that is, all variables must be declared before compiling. Such as:

Integer x;

String y;

X = 1234;

Y = 4321;

Where x = 1234 explains an integer, y = 4321 shows a string.

The variable declarations in JavaScript use their weak type. That is, the variable does not require a statement before use, but the interpreter checks its data type at runtime, such as:

X = 1234;

Y = "4321";

The former explains x for its numerical variable, and the latter explains Y as a character variable.

3. The code format is different

Java is a format that is unrelated to HTML, which must be loaded by referenced to foreign media like HTML, and its code is saved in a separate document in byte code.

JavaScript's code is a text character format that can be embedded directly into the HTML document and can be loaded. Writing an HTML document is as convenient to edit text files.

Embedded mode is different

In the HTML document, the identity of the two programming languages ​​is different, JavaScript uses