Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the program control flow of the structure in JavaScript

Shulou Source: shulou.com Published: 2022-05-31 11:53:33 10月03日 Update

This article mainly explains "what is the program control flow of JavaScript structure". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and go deep into it slowly to study and learn "what is the program control flow of JavaScript structure" together.

1. If conditional statement

Basic format:

if (expression)

Paragraph 1;

......

else

Paragraph 2;

.....

Function: If the expression is true, execute statement segment 1; otherwise execute statement segment 2.

Description: The if-else statement is the most basic control statement in JavaScript, by which you can change the order of execution of statements. The expression must use a relational statement to implement the judgment, which is a Boolean value

to estimate. It converts zero and non-zero numbers to false and true, respectively. If the statement after if has more than one line, it must be enclosed in curly brackets.

Nested format of if statement:

if (Boolean) statement 1;

else (Boolean) statement 2;

elseif (Boolean) statement 3;

……

else statement 4;

In this case, Boolean expressions at each level are evaluated, and if true, their corresponding statements are executed, otherwise the statements after else are executed. Let's look at an example

ifyuju.htm

Mini programs varactivitate =newDate(); activehour= activitate.getHours() if(activehour

Tags: Statement loop program control condition Boolean structure variable format learning case content function increment loop body situation effect expression complex compact Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Tech Info Shulou Information Xiaomi MariaDB