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