First, JavaScript introduction

Source: Internet
Author: User

First, JavaScript introduction

What's a 1.JavaScript thing?

It is a scripting language and requires a host file whose host file is an HTML file.

2. What does it have to do with Java?

There is no direct connection, Java is Sun (has been acquired by Oracle), JavaScript is Netspace (Netscape, has been acquired by AOL), JScript is Microsoft, 90% like JavaScript, some features can only be used on IE.

3. Its usage:

There are three blocks in the HTML position:

(1) Inside head

(2) Body inside

(3) After

For insurance purposes, it is generally written after

<script language= "JavaScript" > code must be placed in this area </script>

4. Three common dialog boxes:

Alert ("") warning dialog box, the function is to pop up a warning dialog box.

Confirm ("") determines the dialog box, the function is to pop up a selection of the OK dialog box, after clicking OK, it returns ture, click Cancel to return False, you can use the variable to receive.

Prompt ("Hint text to display"), which pops up a dialog box that allows you to enter content.

Second, JavaScript syntax (the difference type, but is a weak type of language)

1. Basic Data type:

String, Decimal, Integer, DateTime, Boolean, and so on.

2. Variables:

are generic type Var, can store other types of values, can be used directly, not defined. But it's customary to define.

Defining variables: var A; All variable definitions are defined by Var and var is a generic mutable type. var will be followed by what type you define yourself,

For example: Var a=1;//is defined as a number, which is the integer type

var b= "SS";//Is defined as a string, which is a string type

var c=0.1; Defined as decimals, that is, decimal type

3. Arrays:

Definition of the array: new Array (); Its length is dynamically variable and can be placed in any type of element.

Assignment of array elements: a[0]=123;   a[1]= "Hello"; The index in the element starts at 0.

The value of the array: A[i];

Array properties: A.length; The number and length of array elements.

Method: A.sort ();//array sorting, sorted by the first character of each element.  A.reverse (); Flips the array.

4. Functions:

Four elements of a function: name, input, return value, processing.

Define functions: Function add (formal parameter) {function body}//function named Add, input as parameter, return value can be var type, or return value.

The function must be called to execute. Call to function: Add (argument).

First, JavaScript introduction

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.