What is JavaScript?

Source: Internet
Author: User
Tags html tags

What is JavaScript

JavaScript is a scripting language that is object-based (object) and event-driven (driven) and has a secure performance. Use

It is designed to link to a Web page with HTML Hypertext Markup Language, Java scripting language (Java applets)

Multiple objects that interact with web customers. So that you can develop client applications, and so on. It is by embedding or adjusting into the standard

Implemented in HTML language. Its appearance compensates for the HTML language flaw, it is the Java and the HTML compromise choice, has the following several

Basic Features:

1, is a scripting language
JavaScript is a scripting language that uses small program segments to implement programming. Like other scripting languages, JavaScript is the same as

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

The program is run in a row-by-line explanation. It is combined with HTML tags to facilitate user action.

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

The object that was created. As a result, many features can be derived from the interaction of the methods and scripts of objects in the scripting environment.

3. Simple Nature
The simplicity of JavaScript is mainly embodied in the following: First, it is a simple and compact set based on Java basic statements and control flows

, which is a very good transition for learning java. Second, its variable type is weakly typed and does not use a strict number

According to the type.

4. Safety
JavaScript is a security language that does not allow access to local hard disks and does not allow data to be stored on the server.

Modify and delete the network document, only through the browser to achieve information browsing or dynamic interaction. So as to effectively prevent the loss of data

Lost.

5, dynamic nature of
JavaScript is dynamic and can respond directly to user or customer input without having to go through a Web service program. It to the user's

The response is reflected in an event-driven manner. Event-driven, that is, the main page (home page) in the implementation of a

The action that is produced by an operation is called an event. For example, press the mouse, move the window, select the menu, etc. can be regarded as

Event. When an event occurs, the corresponding event response may be caused.

6. Cross-platform nature
JavaScript is dependent on the browser itself, regardless of the operating environment, as long as the browser can run the computer, and support

JavaScript's browser can be executed correctly. Thus realizing the "write once, all over the world" dream.

In fact, the best thing about JavaScript is that you can do a lot of things with very small programs. Without a high-performance computer, the software needs only

A word processing software and a browser, without the Web server channel, through their own computer can do everything.

The combination of JavaScript is a new descriptive language that can be clamped into HTML files. The JavaScript language can

Respond to user demand events (e.g. form input) without transmitting data back and forth from any network, so when one uses

When a person enters a data, it does not have to pass through to the server to process, and then pass back the process, and directly by the client

(client) is processed by the application.

JavaScript and Java are similar, but not the same! Java is a much more complex programming language than JavaScript.

, while JavaScript is a language that is fairly easy to understand. JavaScript creators can be less focused on programming skills, so

Many Java features are not supported in Java Script.

Three, the difference between JavaScript and Java

Although JavaScript is closely related to Java, it is a different two product developed by two companies. Java is the launch of sun Company

A new generation of object-oriented programming languages, especially for Internet application development, while JavaScript is Netscape

The purpose of the company's products is to extend the Netscape Navigator feature, which can be embedded in a Web page based on

The object and event-driven interpretive language, formerly Live Script, and Java's predecessor is the Oak language. The following two languages

The similarities and differences between the words are compared as follows:

1, object-based and object-oriented
Java is a real object-oriented language, and even if you are developing a simple program, you must design objects.
JavaScript is a scripting language that can be used to create complex software that is unrelated to the network and interacts with the user. It is a

Programming languages that are object-based (object Based) and event-driven (Driver). Thus it itself offers a very rich

Internal objects for use by designers.

2. Interpretation and compilation
The two languages do not perform the same way in their browsers. Java source code must be compiled before being passed to the client for execution

, the client must have an emulator or interpreter on the corresponding platform, which can be implemented independently by the compiler or the interpreter

The binding of a particular platform to compile code.
JavaScript is an interpretative programming language whose source code does not need to be compiled before it is sent to the client, but rather the text

The character code of the type is sent to the client by the browser to interpret the execution.

3, the structure of JavaScript is more free and loose, for example, the variables used in the program before the need for a clear definition, and Java and

Orthodox programming language, the structure is more rigorous.
For example: Strong variables and weak variables
The variables adopted in the two languages are different.
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, using its weak type. The variable is not required to be declared before it is used, but rather the interpreter checks its

Data types, 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.

4, the code format is not the same
JavaScript code is a text character format that can be embedded directly in an HTML document and dynamically loaded. Writing HTML text

File is as handy as editing a text file. and JavaScript must be written in HTML files to view the original code of the page directly,

You can see JavaScript programs, so there's no protection, and anyone can copy programs through HTML files.
Java is an HTML-independent format that must be loaded by means of a reference to an external media like HTML, and its code is in byte-coded

The form is saved in a separate document. Java apps in Web pages are called Java applets (applets are the meaning of applet),

is separate from the HTML file.

5, the embedding method is not the same
In HTML documents, the two programming languages have different identities, JavaScript uses <Script>...</Script> to identify, and Java

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

6. Static and dynamic joint-edit
JavaScript is a document-like description language that can be executed directly through a browser, while Java is like a legitimate programming language.

, such as C + +, must be compiled and connected before the action can be performed.
Java uses a static binder, that is, Java object references must be made at compile time to enable the compiler to implement strong type checking.
JavaScript uses a dynamic binder, that is, JavaScript object references are checked at runtime, and cannot be implemented without compilation

Check for object references.

7, JavaScript does not have read and write files and network control functions (its designers take into account the security of the factors do not provide support

Java provides these features, but JavaScript is the most convenient and efficient way to control and interact with Web content.

Of

Four, JavaScript program operating environment

Software Environment:
· Windows 95/98 or Windows NT.
· Netscape Navigator x.0 or Internet Explorer x.0.
• The character editor (WS, WPS, Notepad, WordPad, and so on) 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 above 640x480.
· The CPU is only less than 233.
• Mouse and other external settings (selected as required).

V. Writing the first JavaScript program

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

into an HTML document.

test1.html Documents:

<script Language = "JavaScript" >
JavaScript appears here.
Alert ("This is the first JavaScript example!");
Alert ("Welcome you into the JavaScript world!");
Alert ("We will learn about JavaScript together in the future!") ");
</Script>
</Head>
</Html>

Description

test.html is an HTML document whose identity format is in standard HTML format;
• Like the HTML markup Language, JavaScript code is text that can be browsed by word processing software that describes the page

The HTML-related area appears.
· JavaScript code consists of <script Language = "JavaScript" >...</Script> description. In the identity <script

Language = JavaScript scripts can be added between "JavaScript" >...</Script>.
alert () is a JavaScript window object method that pops up a string with the OK dialog box and displays ().
• Through the <!--...//--> identification Note: If you do not know the JavaScript code browser, all the identities in it are ignored

, and if so, to carry out its results. Using annotations This is a good programming habit that makes it possible for others to read your language.
· JavaScript ends with a </Script> tag.

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

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.