In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how to understand the sentences of javascript process control". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Process control statements include: 1, if statement; 2, "if...else" statement; 3, "if..else if.." Nested statement; 4, "Switch..case" statement; 5, for statement; 6, while statement; 7, "do...while" statement; 8, "for..in" and so on.
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
1. Make a judgment (if statement)
The if statement is the statement used when the corresponding code is executed based on the condition.
Syntax:
If (condition) {execute code when the condition holds}
Note: if lowercase and uppercase letters (IF) can make errors!
Suppose you apply for a web front-end technology development position, if you know HTML technology, you are successful in the interview, welcome to join the company. The code is as follows:
Var mycarrer = "HTML"; if (mycarrer = = "HTML") {[xss_clean] ("you have a successful interview, welcome to join the company.") ;} 2. Choose one of the two (if...else statement)
The if...else statement executes the code when the specified condition is established and the code after else when the condition is not true.
Syntax:
If (condition) {Code executed when the condition holds} else {Code executed when the condition does not hold}
Suppose you apply for a web front-end technology development position, if you know HTML technology, you are successful in the interview, welcome to join the company, otherwise you will not succeed in the interview and cannot join the company.
The code is as follows:
Var mycarrer = "HTML"; / / the mycarrer variable stores skills if (mycarrer = = "HTML") {[xss_clean] ("you have a successful interview, welcome to join the company.") ;} else / / otherwise, the skill is not HTML {[xss_clean] ("you are not successful in the interview and cannot join the company.") ;} 3. Multiple judgments (if..else if.. Nested statements)
To select one of multiple sets of statements to execute, use if..else if.. Nested statements.
Syntax:
If (condition 1) {code executed when condition 1 holds} else if (condition 2) {code executed when condition 2 holds}... else if (condition n) {code executed when condition n holds} else {code executed when condition 1, 2 to n is not true} 4. Multiple choices (Switch..case statement)
When there are many options, switch is easier to use than if else.
Syntax:
Switch (expression) {case value 1: execute code block 1 break;case value 2: execute code block 2 break;... case value n: execute code block n break;default: code executed at the same time as case value 1, case value 2...case value n}
Syntax description:
The Switch must be assigned an initial value that matches each case value.
Satisfy all statements after the execution of the case and use the break statement to prevent the next case from running.
If all the case values do not match, execute the statement after default.
Assuming that the students' test scores are evaluated with a 10-point system, we grade the scores according to each grade, and make different evaluations according to the grades of the scores.
Note: remember to add the last break statement after the statement executed by case. Otherwise, proceed directly to the following statement in case and look at the following code:
5. Repeat (for loop)
Many things are not just done once, they have to be done repeatedly. If you print 10 test papers, print one at a time, and repeat this action until the printing is completed. These things, we use loop statements to do, loop statements, is to repeat the execution of a piece of code.
For statement structure:
For (initialization variable; Loop condition; Loop iteration) {Loop statement}
If there are six balls in a box, we take one at a time and repeatedly take the ball out of the box until the ball is finished.
Var num=1;for (num=1;num
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.