JavaScript parsing statement

In HTML, JavaScript statements are "executed" by the web browser's "instructions."

Examples

var X, Y, Z;     // statements. 1 
X = 22 is;         // statement 2 
Y =. 11;         // statements. 3 
Z = X + Y;     // statement 4

JavaScript programs

A computer program is a series of computer "instructions", "execution" of.

In programming languages, the programming instructions are called statements.

JavaScript program is a series of programming statements.

Note: In HTML, JavaScript programs are executed by the web browser.

JavaScript statements

JavaScript statement consists of the following:

Value, operators, expressions, and annotation keywords.

This statement tells the browser output id = "demo" HTML elements "Hello Kitty.":

Examples

document.getElementById("demo").innerHTML = "Hello Kitty.";

Most JavaScript program contains a number of JavaScript statements.

These statements will be executed one by one in the order they were written.

Notes: JavaScript program (and JavaScript statements) is often referred to JavaScript code.

Semicolon;

JavaScript statements separated by semicolons.

Please add a semicolon after each executable statement:

a = 5;
b = 6;
c = a + b;

You may see examples without the semicolon online.

Tip: statement ends with a semicolon is not required, but are strongly you to do so.

JavaScript whitespace characters

JavaScript ignores multiple spaces. You can add spaces to the script, to enhance readability.

The following two lines are equivalent:

var person = "Bill";
var person="Bill"; 

In the next operator (= + - * /) is a good idea to add a space:

There x = y + z;

Line length and wrapped JavaScript

For optimum readability, programmers often prefer to control the line of code in less than 80 characters.

If the JavaScript statement is too long, its the best place to break a line is an operator:

Examples

document.getElementById("demo").innerHTML =
 "Hello Kitty.";

JavaScript code block

JavaScript statement (braces {... }) combinations of the code block.

Action code block is executed with the definition statement.

You will see grouped together into a block statement in JavaScript:

function myFunction() {
    document.getElementById("demo").innerHTML = "Hello Kitty.";
    document.getElementById("myDIV").innerHTML = "How are you?";
}

JavaScript Keywords

JavaScript statements are often identified by a keyword need to perform JavaScript actions.

The following table lists the part of the tutorial will learn Keywords:

Key words description
break Termination switch or cycle.
continue Out of the loop and start at the top.
debugger Stop executing JavaScript, and calls the debug function (if available).
do ... while The statements, and repeats the code block when the condition is true.
for Tag statement block needs to be performed, as long as the condition is true.
function Function declaration.
if ... else Tag statement block needs to be performed, in accordance with certain conditions.
return Exit function.
switch Tag statement block needs to be executed, depending on the circumstances.
try ... catch To implement error handling statement block.
where Declare variables.

Notes: JavaScript keyword refers to the word reserved. Reserved words can not be used as a variable name.

Source: www.sysoft.net.cn

Guess you like

Origin www.cnblogs.com/sysoft/p/11616801.html