The core of the JavaScript language and its syntax

    1. Use if and switch statements to make decisions. It is the ability to make decisions that makes code "smart". We can decide whether to perform an action based on whether a condition is true or false.
    2. Comparison operators. Comparison operators can compare the right operand and return a boolean value. The main comparators are as follows:
    1 == Is the left operand equal to the right operand?
    2 ! = Is left operand not equal to right operand?
    3 <= Is the left operand less than or equal to the right operand?
    4 >= Is the left operand greater than or equal to the right operand?
    5 < Is the left operand less than the right operand?
    6 > Is the left operand greater than the right operand?
    Three. if statement. Use the if statement to execute the code in curly braces when the condition is true. The test condition of the if statement is placed in parentheses. If this condition is true, the code after the if statement is executed.
    Four. else statement. If you want the code to execute when the if statement is false, you can use the else statement after the if statement.
    5. Logical operators. Multiple conditions can be combined using the 3 logical operators AND (&&), OR (||), NOT (!).
    1 The AND operator returns true when both expressions are true.
    2 The OR operator returns true when one or both of the expressions on both sides are true.
    3 The NOT operator reverses the logic of an expression.
    Six. switch statement. A switch statement compares the first possible series of possible values ​​with the result of an expression, similar to multiple if statements.
    7. Looping statements: for statement, for...in statement, while statement and do...while statement. Code blocks often need to be executed multiple times, and JavaScript supports the use of loops.
    1 for loop. Used to loop the code a specified number of times. The for loop consists of three parts: initialization, test condition and increment part. The loop continues when the test condition is true. The code block is executed each time the loop is executed, followed by the incrementing portion of the for loop, and then the test condition is recalculated to determine whether the result of the increment changes the result of the test condition.
    2 for...in loops. Used to traverse an array without knowing the number of elements in the array. JavaScript will automatically implement the traversal process without missing any elements.
    3 while loop. Used to loop through code when a test condition is true. The while statement contains a test condition and a block of code that is executed when the test condition is true. If the condition is never true, the code is never executed.
    4 do...while loop. Similar to a while loop, but a do...while loop will execute the code once and then continue executing the code as long as the test conditional statement is true.
    5 break and continue statements. Sometimes it is necessary to end the loop early. The break statement should be used in this case. As soon as a break statement is encountered, execution of the block of code enclosed in curly braces is stopped. Execution starts at the first statement following the closing parenthesis. The continue statement is similar to the break statement. But when the code stops executing at the continue statement, it does not exit the loop, but continues to the next loop.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326633853&siteId=291194637