Js is a scripting language that can be inserted into html web page file, execute in the browser.
Js code a incorporated
- How to insert into the page go?
Use the script tag in the page
2. External introduced
<script src="01.js"></script>
Two code execution sequence
- To load all the tags, from top to bottom
(1) encountered href and src tags and url skip, do not wait.
- Execute script code
three
- Js dialog box provided
alert()
- A warning window pops
- A parameter pop-up content
- No return value
Prompt()
- Input Dialog
- Write two parameters
(1) The first parameter is optional content issue
Default content (2) an optional input box
- There Return The return value is the content of the input box
Confirm()
- Confirmation dialog
- A parameter content
- No return value
Four write-off code
Shortcut key is ctrl +?
// a single line comment / ** / is a multi-line comment
Note: All programming languages underlying (c written by) someone else write a large number of functions.
- Remember the name of the function and purpose
- Look at his parameters
- To see him return value
Five literal
Fixed dead thing, called literal such as
Digital literal 2 2.1 -3.5
String literal "123" "hello" where there have quotes quotes "/ 'regardless of what is inside the quotation marks are all string literal.
Six naming rules
- Chinese characters can not appear
- You can not begin with a number
- Special symbols can not appear @ - / _ and in addition to $
- It can start with a letter and underscore _
- Js keywords can not be used to name.
Seven
Statement: a complete command of js. Later with semicolon (;).
Eight
Js code execution space. Logical space.
Js in the implementation of the code, the computer assigns a memory out.
Sub-memory and execution space
Storage: store kept variables things
Execution space: from top to bottom in order to execute code.
variable
1. Use the keyword var variables are declared
The first thing the computer at the time of execution of the code is to first do all the variables var keyword to declare the existence of storage space to. And then execute code in the implementation process, if you encounter this variable went to look for storage space. There would use, not on the error.
- Assignment of variables (the assignment operator)
= Number to use this variable. The execution order is executed from right to left.
There is 2;
order
First step: a storage space to keep to
The second step: the implementation of the assignment operator: first to find storage space, there is a 2 assigned to a put, not on the error.
Note: In the storage space, the system is actually assigned to the variable value is undefined (unassigned).
During the testing process if the undefined variable storage space but did not appear to have this assignment.
case study
During the assignment, the first to find storage space, there are directly assign a value to this variable, which means it is not no variables (variables not enhance functionality) system will be forced to hang it in the window. It acts as a window in the property.