Beginner Chowder--fifth chapter statement

Source: Internet
Author: User

The fourth Chapter key keywords (expressions)--the phrase corresponding to the sentence is the whole clause or command of JS, end with a semicolon.

An expression evaluates a value, and a statement makes something happen, or some value changes---with a "side effect."

expression Statements : expressions with side effects, such as assignments and function calls , can be used as statements alone.

Compound statement and empty statement : A statement enclosed in curly braces is a compound statement, and an empty statement, such as if (flag), is followed by an empty statement after the conditional statement contains only one statement.

An instance of an empty statement (which does have its usefulness): for (i=0;i<a.length;a[i++]=0);

PS: No semicolon is required at the end of the statement block, no block-level scope

PS: Warm hints, it is best to make a little comment when using empty statements ...

declaration Statements : used to declare new variables (VAR) or to define new variable functions (function), and so on. (You can better organize code and semantics by creating variables and functions)

PS: About variable declaration, priority to write the statement that needs to be assigned to the front; no assignment defaults to undefined

Reiterated:

1. Under the same scope, variable declarations are referred to the top of the execution

2. Declaring a variable many times without a multivariate or affecting a variable

function definitions with functions (two grammatical structures)

First:

var f=function () {};

Second:

function f () {};

function declaration: Feeling can mix this with the definition inside the second to consider

function FuncName ([arg1 [, arg2 [..., argn]]) {

Statements

}

PS: The curly brace of a function must be dropped; A variable declared by a function cannot be deleted, but can be overridden.

Sepcial Word:

The 1.ECMASCRIPT standard specification does not classify a function declaration as a true statement--the function declaration does not appear in the IF statement, while loop, or any other statement ...

2. Declaring functions and function definitions is a bit like a variable declaration, for example: Var a=1;

If this a is a global variable, then when JavaScript is initialized, a is declared, but at this point A is a undefined, and only when the statement is executed, a becomes 1 (refer to chapter III for specific reference).

The corresponding function means that you may be the last to write the function, but you can still call this function before him, for example:

<script>
Console.log (hello ());
function Hello () {
Return "I can";
}
</script>

There is no error, because of the result of the function declaration. The difference from the definition of a variable is that the function declaration is not only in advance of the function name , but also in the body .

3. The practice of placing function declarations within other statements is not portable. (This sentence is not very understanding ...) If you encounter this kind of example and then do research.

4.delete cannot delete functions or variables of var or function declaration. (This is very, very important, you can try it yourself)

used to change the default execution order of statements :

  Conditional Statement : branch, decision Point

if (else), else if, switch

Looping statements: For,while

Jump statement: Break,return,throw

The Ps:javascript program is nothing more than a collection of executable statements.

(Because the project was heavy, the results dragged on for so long ... I really shouldn't ... Currently adjusted to take at least time to complete one chapter per week) to be continued ...

Beginner Chowder--fifth statement

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.