In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use JavaScript Switch sentences". In daily operation, I believe many people have doubts about how to use JavaScript Switch sentences. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use JavaScript Switch sentences". Next, please follow the editor to study!
Use the switch statement to select one of multiple blocks of code that need to be executed.
Grammar
Switch (expression) {
Case n:
Code block
Break
Case n:
Code block
Break
Default:
Default code block
}
Code interpretation:
Evaluate the switch expression once
Compare the value of the expression with the value of each case
If there is a match, the associated code is executed
Example
The getDay () method returns a week name number (weekday number) between 0 and 6.
(Sunday=0, Monday=1, Tuesday=2)
This example uses the week name number to calculate the week's name:
Switch (new Date (). GetDay () {
Case 0:
Day = "Sunday"
Break
Case 1:
Day = "Monday"
Break
Case 2:
Day = "Tuesday"
Break
Case 3:
Day = "Wednesday"
Break
Case 4:
Day = "Thursday"
Break
Case 5:
Day = "Friday"
Break
Case 6:
Day = "Saturday"
}
The result will be:
Today is Thursday.
At this point, the study of "how to use JavaScript Switch sentences" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.