What is JavaScript?

Source: Internet
Author: User

What is JavaScript?

JavaScript is a scripting language based on Object and Event-Driven with secure performance. Use

It is linked to a Web page together with HTML hypertext markup language and Java scripting language (Java applet ).

Multiple objects that interact with Web customers. This allows you to develop client applications. It is embedded or transferred in the Standard

Implemented in HTML. Its appearance makes up for the defects of the HTML language. It is a compromise between Java and HTML and has the following

Basic features:

1. It is a scripting language.
JavaScript is a scripting language that uses small program segments for programming. Like other scripting languages, JavaScript is the same

This is already an explanatory language that provides an easy development process.
Its basic structure is similar to C, C ++, VB, and Delphi. But unlike these languages, it needs to be compiled first, but in

It is explained line by line during the program running. It is combined with HTML tags to facilitate user operations.

2. Object-based language.
JavaScript is an object-based language and can be viewed as an object-oriented language. This means that it can use its own

The created object. Therefore, many functions can come from the interaction between methods of objects and scripts in the script environment.

3. Simplicity
The simplicity of JavaScript is mainly reflected in: first, it is a simple and compact setup based on the Basic Java statements and control flow.

Learning Java is a very good transition. Second, its variable type is weak, and no strict number is used.

Data type.

4. Security
JavaScript is a security language. It does not allow access to a local hard disk, nor store data on the server.

Modify and delete network documents. You can only use a browser to browse information or perform dynamic interaction. This effectively prevents data loss.

Loss.

5. Dynamic
JavaScript is dynamic and can respond directly to user or customer input without passing through Web service programs. It

The response is event-driven. Event-driven refers to executing

The action generated by an operation is called an Event ). For example, you can press the mouse, move the window, and select a menu.

Event. When an event occurs, it may cause the corresponding event response.

6. cross-platform
JavaScript depends on the browser itself and has nothing to do with the operating environment. As long as it can run the computer of the browser and supports

The JavaScript browser can be correctly executed. Thus realizing the dream of "writing once and going all over the world.

In fact, the most outstanding thing about JavaScript is that it can do a lot of things with a very small program. High-performance computers are not required.

A word processing software and a browser can accomplish everything through your computer without the need for WEB Server channels.

In summary, JavaScript is a new description language that can be merged into HTML files. The JavaScript language is acceptable.

To respond to user requirements (such as form input), instead of transmitting data back and forth over any network

When a user inputs a data item, it does not need to pass it to the servo end (server) for processing, but can be directly sent back by the client

(Client.

JavaScript and Java are very similar, but they are not the same! Java is a program language that is much more complex than JavaScript.

JavaScript is a language that is quite easy to understand. JavaScript creators can focus less on program skills, so

Many Java features are not supported in Java scripts.

Iii. Differences between JavaScript and Java

Although JavaScript is closely related to Java, it is two different products developed by two companies. Java was launched by SUN.

The new-generation object-oriented programming language, especially suitable for Internet application development; while JavaScript is a Netscape

The purpose of the company's products is to expand the Netscape Navigator function, and a kind of product that can be embedded in Web Pages Based on

Object and event-driven explanatory language. Its predecessor is Live Script, and Java's predecessor is Oak. Two languages

The similarities and differences between languages are compared as follows:

1. Object-based and object-oriented
Java is a real object-oriented language. Even a simple program must be designed.
JavaScript is a scripting language that can be used to create complex software that is unrelated to the network and interacts with users. It is

An Object-Based and Event Driver-Based programming language. Therefore, it provides a wealth

Internal objects for use by designers.

2. Interpretation and compilation
The two languages are executed in different ways in their browsers. Java source code must be compiled before it is passed to the client for execution.

Therefore, the client must have a simulator or interpreter on the corresponding platform. It can be implemented independently

Compilation code constraints on a specific platform.
JavaScript is an interpreted programming language. Its source code does not need to be compiled before it is sent to the client for execution.

The character code is sent to the client for explanation and execution by the browser.

3. The structure of JavaScript is loose. For example, the variables used in the program do not need to be clearly defined, but Java and

Like the Orthodox programming language, the structure is more rigorous.
For example, strong variables and weak Variables
The variables used by the two languages are different.
Java uses a strongly typed variable check, that is, all variables must be declared before compilation. For example:

Integer x;
String y;
X = 1234;
X = 4321;

X = 1234 indicates an integer, and Y = 4321 indicates a string.
The variable declaration in JavaScript uses its weak type. That is, variables do not need to be declared before they are used, but the interpreter checks their

Data type, such:

X = 1234;
Y = "4321 ";

The former indicates that x is its numeric variable, while the latter indicates that y is a numeric variable.

4. Different Code formats
JavaScript code is a text character format that can be directly embedded into HTML documents and loaded dynamically. Compile HTML

Files are as convenient as editing text files. In addition, JavaScript must be written in an HTML file to directly view the original code of the webpage,

You can see JavaScript programs, so there is no protection. Anyone can copy programs through HTML files.
Java is an HTML-independent format, which must be loaded by referencing external media like HTML.

Format is saved in a separate document. A Java application program on a webpage is called a Java Applet ),

Is separate from HTML files.

5. Different embedding Methods
In HTML documents, the two programming languages have different identifiers. JavaScript uses <Script>... </Script> to identify, while Java

Use <applet>... </applet> to identify.

6. Static and Dynamic Association editing
JavaScript is a file-like description language that can be directly executed through a browser. Java is like an orthodox programming language.

(For example, C/C ++), you must first compile, link, and other actions before execution.
Java uses static concatenation, that is, Java object reference must be carried out during compilation, so that the compiler can implement forced type check.
JavaScript uses dynamic concatenation, that is, JavaScript Object Reference is checked during runtime. It cannot be implemented without compilation.

Object Reference check.

7. JavaScript does not have functions such as reading and writing files and network control (its designers did not provide support for security considerations

Java provides these functions, but JavaScript is the most convenient and convenient in terms of webpage content control and interaction.

.

Iv. JavaScript running environment

Software environment:
· Windows 95/98 or Windows NT.
· Netscape Navigator x.0 or Internet Explorer x.0.
· The character editor used to edit HTML documents (WS, WPS, Notepad, WordPad, etc.) or HTML document editor.

Hardware configuration:
First, you must have the basic hardware configuration environment for running Windows 95/98 or Windows NT. Recommended:
· The basic memory is 32 MB.
· The CRT only needs 256 less colors, and the resolution is above 640x133.
· CPU usage is less than 233.
· Mouse and other external settings (as needed ).

5. Compile the first JavaScript Program

The following is an example to compile the first JavaScript program. It shows how JavaScript scripts are embedded.

To the HTML document.

Test1.html document:

<Html>
<Head>
<Script Language = "JavaScript">
// JavaScript Appears here.
Alert ("This is the first JavaScript example! ");
Alert ("welcome to the JavaScript world! ");
Alert ("we will learn JavaScript knowledge together in the future! ");
</Script>
</Head>
</Html>

Note:

· Test.html is an HTML document whose identification format is standard HTML format;
· Like the HTML identification language, JavaScript code is a text that can be viewed by word processing software. It is displayed on the description page.

.
· JavaScript code is described by <Script Language = "JavaScript">... </Script>. In the identifier <Script

You can add JavaScript scripts between languages = "JavaScript">... </Script>.
· Alert () is a JavaScript window object method. Its function is to pop up a string with an OK dialog box and display.
· Pass <! --... // --> Description: if you do not know the JavaScript code browser, all the identifiers in it will be ignored.

If yes, the result is executed. Using annotations is a good programming habit, which allows others to understand your language.
· JavaScript ends with the </Script> label.

From the instance analysis above, we can see that writing a JavaScript program is indeed very easy.

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.