In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what are the choice sentences in javascript", friends who are interested may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what are the choice statements in javascript"?
Select statements are: 1, if statement, syntax "if (conditional expression) {/ / code} else {/ / code}"; 2, switch statement, syntax "switch (expression) {case value: statement; break;..}"; 3, ternary operation statement, syntax "conditional expression? expression 1: expression 2;"
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
1. If statement
This place is similar to a common language and has the following format:
If (test condition) {execute when the test condition is true} else {execute when the test condition is false}
Else can be omitted, such as the following
If (test condition) {test condition is executed when it is true}
You can use curly braces when you have a single line, for example
If (3 > 6) alert ("A"); else alert ("B")
Multi-branch if statement
This is similar to other languages, where multiple branches are executed only once. The format is as follows:
If (test condition 1) {test condition 1true execution statement} else if (test condition 2) {test condition 2true execution statement} else if (test condition) {test condition 3true execution statement} else {test condition 4true execution statement}
Nesting of if statements
If (test condition) {if (test condition) {execute} 2, switch statements when the test condition is true
Same as c, the syntax format is as follows:
Switch (variable) {case value 1: statement executed equal to value 1; break; case value 2: statement executed equal to value 2; break; case value 3: statement executed equal to value 3; break Case value 4: a statement executed equal to value 4; break; default: a statement that is not equal to the above values; break;} 3, ternary operation
Similar to c, the format is as follows:
Conditional expression? Expression 1: expression 2; at this point, I believe you have a deeper understanding of "which choice statements in javascript". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.