In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces which sentences are commonly used in JavaScript. It is very detailed and has a certain reference value. Friends who are interested must finish it!
1.switch
Select one of a plurality of code blocks to be executed
Switch (e) {case 1: / / e for 1 execution here break; case 2: / / e for 2 execution here break; default: / / is not satisfied for execution here}
Note:
You don't have to interrupt the last case in the switch code block with break. The code block ends naturally here.
Switch case uses a strict comparison (= =), and the value must be the same as the type to match.
If JavaScript encounters a break keyword, it will jump out of the switch code block, so that the system will not continue to execute, which can improve performance.
2.While cycle
If the following conditions are not met, it will loop until the parameter "I" is not less than 10.
While (I < 10) {text + = "number is" + I; iTunes;} 3.Do/While loop
This is similar to the above, but it will be executed at least once, because it is executed first and then judged.
Do {text + = "The number is" + I; iTunes;} while (I < 10)
For-Loop can execute a block of code a specified number of times.
For/in-Loop through the properties of the object
While-Loop the specified block of code when the specified condition is true
Do/while-also loop the specified code block when the specified condition is true, but the loop executes the code block once before determining the condition
3. String conversion number
Many students will encounter string conversion numbers, the converted words can not remember, or lazy to write, then directly add a + sign in front of the variable
Like this:
Let a = "12" / / this is a string console.log (+ a) / / now converted to the number 12. These are all the contents of the article "what are the commonly used sentences in JavaScript?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.