if conditional judgment statement in JavaScript

if conditional judgment statement:

#If the condition is true, what code will be executed; if the condition is not true, what code will be executed


Structure 1: Only judge true (true), if the condition is false, do nothing

if (Conditional judgment: the judgment result is a Boolean value)

{

The condition is true (true), the executed code

}


## Structure 2: Both true and false

if (Conditional judgment)

{

If the condition is true, the code to be executed

}else

{

The condition is false, the code to be executed Code

}


# Structure 3: Multi-condition judgment
if(Condition 1)

{

Code 1;

}else if(Condition 2)

{

Code 2;

}else if(condition 3)

{

Code 3;

}else

{

If none of the above conditions are true, execute this code;

}

Note: Although there are multiple conditions, there is an "OR" relationship between the conditions. . At any moment, only one condition can be true, and multiple conditions cannot be met at the same time.

    php.cn  

Continuing Learning
||
php.cn
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!