js a base (introduction, pop, naming rules, etc.)

Js is a scripting language that can be inserted into html web page file, execute in the browser.

Js code a incorporated

  1. 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

  1. To load all the tags, from top to bottom

(1) encountered href and src tags and url skip, do not wait.

  1. Execute script code

three

  1. Js dialog box provided

alert()

  1. A warning window pops
  2. A parameter pop-up content
  3. No return value

Prompt()

  1. Input Dialog
  2. Write two parameters

(1) The first parameter is optional content issue

Default content (2) an optional input box

  1. There Return The return value is the content of the input box

Confirm()

  1. Confirmation dialog
  2. A parameter content
  3. 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.

  1. Remember the name of the function and purpose
  2. Look at his parameters
  3. 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

  1. Chinese characters can not appear
  2. You can not begin with a number
  3. Special symbols can not appear @ - / _ and in addition to $
  4. It can start with a letter and underscore _
  5. 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.

  1. 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.

Guess you like

Origin www.cnblogs.com/zhangyuxinxin/p/12090361.html