zoukankan      html  css  js  c++  java
  • javaScript 5

    表达式语句

    Assignment statements are one major category of expression statements.

    The delete operator has the important side effect of deleting an object property.

    Function calls are another major category of expression statements.

    复合语句和空语句

    A statement block is simply a sequence of statements enclosed within curly braces.

    {
                 x = Math.PI;
                 cx = Math.cos(x);
                 console.log("cos(π) = " + cx);
             }

    First, it does not end with a semicolon. The primitive statements within the block end in semicolons, but the block itself does not.

    Second, the lines inside the block are indented relative to the curly braces that enclose them. This is optional, but it makes the code easier to read and understand.

    Finally, JavaScript does not have block scope and variables declared within a statement block are not private to the block.

    用一个分号可以表示空语句,是否也可以用{}表示空语句呢?

    声明语句

    var

    If a var statement appears within the body of a function, it defines local variables, scoped to that function. When var is used in top-level code, it declares global variables, visible throughout the JavaScript program.

    If no initializer is specified for a variable with the var statement, the variable's initial value is undefined.

    Note that it is harmless to declare the same variable multiple times.

    function

    function definition expression:

    var f = function(x) { return x+1; } // Expression assigned to a variable

    function definition statement:

    function f(x) { return x+1; } // Statement includes variable name

    Function definitions may not appear within if statements, while loops, or any other statements.

    条件语句

    if

    The rule in JavaScript is that by default an else clause is part of the nearest if statement.

    else if

    else if is not really a JavaScript statement, but simply a frequently used programming idiom that results when repeated if/else statements are used.

    switch

    When a switch executes, it computes the value of expression and then looks for a case label whose expression evaluates to the same value (where sameness is determined by the === operator).

    循环

    while

    do/while

    for

    for/in

    属性枚举的顺序

    跳转

    标签语句

    break语句

    continue语句

    return语句

    throw语句

    try/catch/finally语句

    其他类型语句

  • 相关阅读:
    linux内存管理之数据结构必备
    Script快速入门与查表
    Bash编程linux诸多熟记命令
    NandFlash/NorFlash源码模型和驱动编写方法
    linux内存管理之uboot第一步
    《Magus Night》
    《P2447 [SDOI2010]外星千足虫》
    DFS 树的理解
    《2021CCPC桂林》
    《GRAPH》
  • 原文地址:https://www.cnblogs.com/cuishengli/p/2630479.html
Copyright © 2011-2022 走看看