1. switchSelect one of multiple code blocks to be executed switch(e) { case 1: //e is 1, execute break here; case 2: //e is 2, execute break here; default: // None of them meet the requirements to execute here} Notice:
2. While LoopIf the following condition is not met, the loop will continue until the parameter "i" is not less than 10 while (i < 10) { text += "The number is" + i; i++; } 3. Do/While LoopThis 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; i++; } while (i < 10);
3. Convert string to numberMany students will encounter the problem of converting strings to numbers, but they can't remember the words to convert, or they are too lazy to write them. In this case, just add a + sign in front of the variable. Like this: let a = "12" // This is a string console.log(+a) // Now it is converted to the number 12 This concludes this article about common JavaScript statements for loops, judgments, and string to number conversion. For more related content on common JavaScript statements, please search previous articles on 123WORDPRESS.COM or continue browsing the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
>>: Solution for Baidu site search not supporting https (tested)
Ubuntu 18.04, other versions of Ubuntu question: ...
Table of contents 1. Prerequisites 1.1 Supported ...
1. Download 1. Click the latest download from the...
MySQL 5.5 installation and configuration method g...
Using the <img> element with the default sr...
Table of contents 1. DHCP Service (Dynamic Host C...
Table of contents 1. Why Redux 2. Redux Data flow...
April 23, 2020, Today, Ubuntu 20.04 on Windows al...
Countdown function needs to be implemented in man...
The color presentation on a web page will be affec...
Table of contents Preface Single file components ...
The default template method is similar to vue2, u...
There are two solutions: One is CSS, using backgro...
Table of contents Preface environment Install Cre...
question The code has no prompt: Many non-front-e...