In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the judgment structure of javascript". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the judgment structure of javascript".
Judgment structure: 1, if conditional branch structure, including if, "if else", "if else if …", "if else if … else" statements; 2, "switch case" conditional branch structure; 3, ternary operation structure, grammar "condition? expression 1: expression 2".
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
Branch structure is our common judgment structure, according to the conditions set by the user to determine whether to execute certain code programs, the following Xiaoqian will introduce to you three common branch structure syntax.
IF conditional branching structure
If statement
An if statement is used to determine whether the code is executed or not
Syntax: if (condition) {Code to be executed}
Determine whether the code in {} is executed by whether the condition in () is true or not.
If else statement
Decide which {} code to execute according to the if condition
Syntax: if (condition) {execute when condition is true} else {execute when condition is false}
One of the code within the two {} must be executed
If else if... Statement
You can use if and else if to set multiple conditions to judge
Syntax: if (condition 1) {execute when condition 1 is true} else if (condition 2) {execute when condition 2 is true}
If the first condition is true, then the content in the following {} will be executed.
If the first condition is false, then the second condition is judged, and so on.
Of multiple {}, only one will be executed. Once there is a condition of true, the latter will not be judged.
If else if... Else statement
And the previous if else if... Basically the same, but when all the conditions are not met, execute the {} after the last else
SWITCH conditional branching structure
It is also a kind of conditional judgment sentence, which is the judgment of a certain variable.
Syntax:
To judge that a variable is equal to a certain value to use
Example: the number given according to the variable shows what day it is
Ternary operation (extension)
Ternary operation is to use two symbols to form a statement.
Ternary operation is just an abbreviated form of if else statement.
Grammar: condition? Execute when condition is true: execute when condition is false
Thank you for reading, the above is the content of "what is the judgment structure of javascript". After the study of this article, I believe you have a deeper understanding of what is the judgment structure of javascript, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.