JavaScript language Overview

Source: Internet
Author: User

The internet era has created our new work and the way of life, its interconnection, openness and the sharing of information patterns, breaking the traditional way of information dissemination of the barriers, to bring us new opportunities. With the advent of the computer and Information age, the pace of human society is accelerating gradually, every day there are new things happen, every day in the creation of miracles. With the rapid development of Internet technology, all walks of life join the Internet industry. The internet can bring infinite vitality, both in terms of management and from a business standpoint. Through the Internet, regional, collective and even individual connections can be achieved, thus achieving a "unified harmony." So how to add their own or company's information resources to the WWW server, is a growing concern for the users. Using Hyper-chain technology (hypertext and Hypermedia technology) is the simplest and quickest way to achieve this goal. The implementation of this means of support environment, that is HTML hypertext Identification language. You can create the Web pages you want with them.

Through hypertext (Hyper Text) and Hypermedia (Hyper Media) technology combined with hyperlinks (Hyper link), various information is organized into a network structure (web), which forms a network document, which enables "roaming" on the internet. The text, table, sound, image, animation and other multimedia information can be retrieved through the description of HTML symbols. Rl.82676666.com

However, the use of this hyper-chain technology has some shortcomings, that is, it can only provide a static information resources, the lack of dynamic client-server interaction. Although some interaction can be achieved through the CGI (Common Gateway Interface) Universal Gateway Interface, the programming of this method is more complicated, which hinders the development of Internet technology for some time. And the advent of JavaScript, non-coagulation for Internet users brought chance. It can be said that the advent of JavaScript is the needs of the times, is today's information age has created JavaScript.

The advent of JavaScript, it can make the information and users not only a display and browsing relationship, but to achieve a real-time, dynamic, and the ability to communicate the expression. Thus, CGI-based static HTML pages will be replaced by Web pages that provide dynamic real-time information and respond to customer actions. JavaScript scripts are the language that is created to meet this need. It is popular with a wide range of users. It is a very good one in many scripting languages, and its combination with WWW effectively realizes the blueprint of Network Computing and network computer. The non-condensing Java family occupies the dominant position of Internet networks. Therefore, mastering the JavaScript scripting language programming method as soon as possible is becoming more and more concerned by our customers.

First, what is JavaScript

JavaScript is a scripting language that is Object-based (objects) and event-driven (driven) and has security performance. It is used in conjunction with HTML Hypertext Markup Language, Java scripting language (Java applet) to link multiple objects in a single Web page, interacting with web customers. So that you can develop client applications and so on. It is implemented in the standard HTML language by embedding or inserting. Its appearance makes up for the HTML language flaw, it is the Java and the HTML compromise choice, has the following several basic characteristics:

scripting language

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

Its basic structure form and C, C + +, VB, Delphi very similar. But unlike these languages, it needs to be compiled and interpreted on a row-by-line basis in the course of a program's operation. It is combined with the HTML identity to facilitate the user's use of the operation.

Object-based language

JavaScript is an object-based language that can be viewed as an object-oriented one. This means that it can use the objects that it has created. Therefore, many functions can be derived from the interaction of the methods of the objects in the scripting environment with the script.

Simplicity of

The simplicity of JavaScript is mainly reflected in the following: First, it is a simple and compact design based on Java basic statements and control flow, which is a very good transition for learning java. Second, its variable type is weakly typed and does not use strict data types. M.hrbfc120.com

Security

JavaScript is a security language that does not allow access to local hard disks, does not store data on the server, does not allow modification and deletion of network documents, and can only be browsed or dynamically interacted through a browser. So as to effectively prevent the loss of data.

Dynamic nature

JavaScript is dynamic, and it can respond directly to user or customer input without having to go through a Web service program. It responds to the user in an event-driven manner. Event-driven refers to the action that occurs when an action is performed on the home page, called an event. For example, pressing the mouse, moving the window, selecting a menu, and so on can be considered as events. When an event occurs, a corresponding event response may be caused.

Platform-based

JavaScript is dependent on the browser itself, regardless of the operating environment, as long as the browser can run the computer, and support JavaScript browser can be executed correctly. Thus realized the "write once, traveled the world" dream.

In fact, the best thing about JavaScript is that you can do a lot of things with very small programs. No need to have a high-performance computer, the software only need a word processing software and a browser, without the Web server channel, through their own computer can do all things.

Synthesis of the JavaScript is a new description language, it can be clamped into the HTML file. The JavaScript language can be used to respond to the user's needs events (such as the input of a form), instead of transmitting data back and forth from any network, so when a user inputs a data, it does not pass to the server to process, and then return the process, and directly can be the client ( Client) is handled by the application.

JavaScript is similar to Java, but it's not the same! Java is a much more complex programming language than JavaScript, while JavaScript is a fairly easy-to-understand language. JavaScript creators can focus less on programming skills, so many Java features are not supported in Java Script.

Ii. the difference between JavaScript and Java

Although JavaScript is closely linked to Java, it is the two different products developed by the two companies. Java is a new generation of object-oriented programming language from Sun, which is especially suitable for Internet application development, and JavaScript is the product of Netscape company, which is designed to extend Netscape Navigator function, And the development of an object-based and event-driven interpretive language that can be embedded in Web pages, formerly known as Live Script, and Java's predecessor is the Oak language. The following comparisons are made between the two languages:

Object-based and object-oriented

Java is a true object-oriented language, and even if you are developing a simple program, you must design the object.

JavaScript is a scripting language that can be used to create complex software that is independent of the network and interacts with the user. It is a programming language based on objects (object Based) and event-driven events Driver. Thus it itself provides a very rich interior object for designers to use.

Interpreting and compiling

The two languages do not perform the same way in their browsers. Java's source code must be compiled before it is passed to the client, so the client must have an emulator or interpreter on the appropriate platform, which can be implemented independently of a particular platform by compiler or interpreter.

JavaScript is an explanatory programming language whose source code is not compiled until it is sent to the client, but instead sends a text-formatted character code to the client to interpret the execution by the browser.

Strong variables and weak variables

The variables taken in both languages are not the same. M.120hrb.com

Java uses strongly typed variables to check that all variables must be declared before they are compiled. Such as:

Integer x;

String y;

x=1234;

x=4321;

Where the x=1234 description is an integer, the y=4321 description is a string.

A variable declaration in JavaScript with its weak type. That is, the variable does not need to be declared before it is used, but rather the interpreter checks its data type at run time, such as:

x=1234;

Y= "4321";

The former indicates that x is a numeric variable, while the latter indicates that Y is a character variable.

Code format not the same

Java is an HTML-independent format that must be loaded by referencing an external media like HTML, and its code is stored in a separate document in the form of a byte code.

JavaScript code is a text character format that can be embedded directly into an HTML document and dynamically loaded. Writing an HTML document is as easy as editing a text file.

Not embedded in the same way

In an HTML document, the identities of the two programming languages are different, JavaScript is used to identify them, and Java is used to identify them.

Static and dynamic linking

Java uses static linking, meaning that Java object references must be made at compile time, so that the compiler can implement strong type checking.

JavaScript uses dynamic linking, in which JavaScript object references are checked at run time and cannot be checked for object references without compiling.

Third, JavaScript program operating environment

Java Runtime Environment

Software Environment:

Windows 95/98 or Windows NT.

Netscape Navigator x.0 or Internet Explorer x.0.

Character Editor (WS, WPS, Notepad, WordPad, etc.) or HTML document editor for editing HTML documents.

Hardware configuration:

You must first have a basic hardware configuration environment running Windows 95/98 or Windows NT. Recommended:

Basic memory 32M.

CRT only needs 256 colors, resolution in 640x480 above.

The CPU is only less than 233.

Mouse and other external settings (as needed).

Iv. writing the first JavaScript program

Let's use an example to write the first JavaScript program. It shows how JavaScript scripts are embedded in HTML documents.

Test1.html Documentation:

The result of running the line in Internet Explore5.0 is shown in Figure 1-1. Www.hrbnzyy.com

Figure 1-1 The results of the program run

Description: test.html is an HTML document whose identity format is in standard HTML format;

Like the HTML identity language, the JavaScript program code is a text that can be browsed by word-processing software, which appears in the HTML-related area of the description page.

The JavaScript code is explained by. A JavaScript script can be added between identities.

Alert () is a JavaScript window object method whose function is to eject a string that has an OK dialog box and displays ().

By means of identification: If you do not know the JavaScript code of the browser, then all the identities therein are ignored, and if so, the result is executed. Using annotations This is a good programming habit that allows others to read your language.

JavaScript ends with a label.

JavaScript language Overview

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.