JS基础_break和continue

 1 <!DOCTYPE html>
 2 <html>
 3     <head>
 4         <meta charset="UTF-8">
 5         <title></title>
 6         <script type="text/javascript">
 7             
 8             /*
 9              * break关键字可以用来退出switch或循环语句
10              *     不能在if语句中使用break和continue
11              *     break关键字,会立即终止离他最近的那个循环语句
12              */
13             
14             //---------------------------------------------------------------------------------
15             
16             for(var i=0 ; i<5 ; i++){
17                 console.log(i); //0  1 2
18                 
19                 if(i == 2){
20                     break;
21                 }
22                 
23             }
24             
25             
26             for(var i=0 ; i<5 ; i++){
27                 console.log("@外层循环"+i) //@外层循环0 @外层循环1 @外层循环2 @外层循环3 @外层循环4
28                 for(var j=0 ; j<5; j++){
29                     break;
30                     console.log("内层循环:"+j);
31                 }
32             }
33             
34             //---------------------------------------------------------------------------------
35             
36             /*
37              * 可以为循环语句创建一个label,来标识当前的循环
38              * label:循环语句
39              * 使用break语句时,可以在break后跟着一个label,
40              *     这样break将会结束指定的循环,而不是最近的
41              */
42             
43             outer:
44             for(var i=0 ; i<5 ; i++){
45                 console.log("@外层循环"+i) // @外层循环0
46                 for(var j=0 ; j<5; j++){
47                     break outer;
48                     console.log("内层循环:"+j);
49                 }
50             }
51             
52             
53             /*
54              * continue关键字可以用来跳过当次循环
55              *     同样continue也是默认只会对离他最近的循环循环起作用
56              */
57             for(var i=0 ; i<5 ; i++){
58                 
59                 if(i==2){
60                     continue;
61                 }
62                 
63                 console.log(i); //0 1 3 4    
64             }
65             
66             
67             outer:
68             for(var i=0 ; i<5 ; i++){
69                 
70                 for(var j=0 ; j<5 ; j++){
71                     
72                     continue;
73                     
74                     console.log("-->"+j);
75                     
76                 }
77                 
78                 console.log("@--->"+i);//@--->0 @--->1 @--->2 @--->3 @--->3
79             }
80             
81             
82         </script>
83     </head>
84     <body>
85     </body>
86 </html>

 

转载于:https://www.cnblogs.com/ZHOUVIP/p/7678707.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/428672.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

538B. Quasi Binary

B. Quasi Binary&#xff1a;题目 这题目建议挪到1000分&#xff0c;它不配1400#include <bits/stdc.h> using namespace std; #define int long long vector<int> a((int)6e5); vector<int> b((int)6e5), c((int)6e5); const int mod 1e9 7; signed main…

289B. Polo the Penguin and Matrix

B. Polo the Penguin and Matrix&#xff1a;题目 思路&#xff1a;纯暴力#include <bits/stdc.h> using namespace std; // #define int long long vector<int> a((int)6e5); vector<int> b((int)6e5), c((int)6e5); const int mod 1e9 7; int g[111][11…

HDU 1525 类Bash博弈

给两数a,b&#xff0c;大的数b b - a*k,a*k为不大于b的数,重复过程&#xff0c;直到一个数为0时&#xff0c;此时当前操作人胜。 可以发现如果每次bb%a&#xff0c;那么GCD的步数决定了先手后手谁胜&#xff0c;而每次GCD的一步过程视为一个子游戏&#xff0c;但是可以发现如果…

HDU 3094 树上删边 NIM变形

基本的树上删边游戏 写过很多遍了 /** Date : 2017-10-13 18:19:37* FileName: HDU 3094 树上删边 NIM变形.cpp* Platform: Windows* Author : Lweleth (SoungEarlfgmail.com)* Link : https://github.com/* Version : $Id$*/ #include <bits/stdc.h> #define LL …

1320A. Journey Planning

A. Journey Planning&#xff1a;题目 mp的应用&#xff0c;和下标同样的差一定会越来越大&#xff0c;知道这点就好写了。#include <bits/stdc.h> using namespace std; #define int long long vector<int> a((int)6e5); vector<int> b((int)6e5), c((int)…

1245C. Constanze‘s Machine

C. Constanze’s Machine&#xff1a;题目 众所周知&#xff0c;斐波那契数列属于dp#include <bits/stdc.h> using namespace std; #define int long long vector<int> a((int)6e5); vector<int> b((int)6e5), c((int)6e5); const int mod 1e9 7; map<…

常见三种字符编码的区别:ASCII、Unicode、UTF-8

什么是字符编码&#xff1f; 计算机只能处理数字&#xff0c;如果要处理文本&#xff0c;就必须先把文本转换为数字才能处理。最早的计算机在设计时采用8个比特&#xff08;bit&#xff09;作为一个字节&#xff08;byte&#xff09;&#xff0c;所以&#xff0c;一个字节能表…

1108D. Diverse Garland

D. Diverse Garland&#xff1a;题目 什么脑瘫题目&#xff01;&#xff01;&#xff01;可恶&#xff0c;和dp有什么关系&#xff1f;但是强迫症让我不得不写&#xff0c;空一个很难受&#xff01;&#xff01;#include <bits/stdc.h> using namespace std; #define in…

Oracle存储过程procedure in、out、in out 模式参数【不发布,纯转】

Oracle存储过程procedure in、out、in out 模式参数 Oracle存储过程基本语法介绍 注意存过不会自动提交,需要在存过本身添加commit; rollback;等语句转载于:https://www.cnblogs.com/whatlonelytear/p/7680383.html

1451C. String Equality

C. String Equality&#xff1a;题目 我也不知道这算不算dp....虽然它有一个dp的标签#include <bits/stdc.h> using namespace std; #define int long long vector<int> a((int)6e5); vector<int> b((int)6e5), c((int)6e5); const int mod 1e9 7; int mp…

导航,头部,CSS基础

制作自己的导航条。HTML头部元素&#xff1a;<base> 定义了页面链接标签的默认链接地址<style> 定义了HTML文档的样式文件<link> 定义了一个文档和外部资源之间的关系练习样式表&#xff1a;行内样式表内嵌样式表外部样式表分别练习定义三类选择器&#x…

1535C. Unstable String

C. Unstable String题目 每个&#xff1f;只能选择变一次&#xff0c;然后不能变了&#xff0c;这是关键。#include <bits/stdc.h> using namespace std; #define int long long vector<int> a((int)6e5); vector<int> b((int)6e5), c((int)6e5); const int…

十五、导航,头部,CSS基础

制作自己的导航条。HTML头部元素&#xff1a;<base> 定义了页面链接标签的默认链接地址<style> 定义了HTML文档的样式文件<link> 定义了一个文档和外部资源之间的关系 练习样式表&#xff1a;行内样式表内嵌样式表外部样式表分别练习定义三类选择器&#…

js形参(parameter)和实参(argument)

parameter&#xff1a;形参_函数中包含的参数 Parameter 属于变量&#xff0c;用于存储传递到函数中的数据&#xff0c;并供函数使用 argument&#xff1a;实参_函数实际运行中使用的参数 Argument 是当函数被调用时传递到函数中的实际数据转载于:https://www.cnblogs.com/miao…

1461B. Find the Spruce

B. Find the Spruce&#xff1a;题目 题意&#xff1a;找有多少树状结构。 思路&#xff1a;递推&#xff0c;从下往上算树尖。#include <bits/stdc.h> using namespace std; #define int long long vector<int> a((int)6e5); vector<int> b((int)6e5), c((…

ajax跨域请求问题总结

总结一下近期遇到ajax跨域请求问题 业务场景描述&#xff1a; 移动端页面放在阿里云服务器进入页面后&#xff0c; 需要访问另一个服务器的接口&#xff0c;ajax请求使用用GET,POST,PUT等方法服务端需要进行cors配置操作过程中出现的问题 发送PUT请求时&#xff0c;请求头的met…

987C. Three displays

C. Three displays&#xff1a;题目 #include <bits/stdc.h> using namespace std; #define int long long vector<int> a((int)6e5); vector<int> b((int)6e5), c((int)6e5); const int mod 1e9 7; int sum[3333][4]; signed main() {int n;cin >>…

连接池

数据库连接池 锁定本词条由“科普中国”百科科学词条编写与应用工作项目 审核 。数据库连接池负责分配、管理和释放数据库连接&#xff0c;它允许应用程序重复使用一个现有的数据库连接&#xff0c;而不是再重新建立一个&#xff1b;释放空闲时间超过最大空闲时间的数据库连接…

1276A. As Simple as One and Two

A. As Simple as One and Two&#xff1a;题目 思路&#xff1a;删去中间#include <bits/stdc.h> using namespace std; #define int long long vector<int> a((int)6e5); vector<int> b((int)6e5), c((int)6e5); const int mod 1e9 7; string s; signed …

【网络爬虫入门04】彻底掌握BeautifulSoup的CSS选择器

【网络爬虫入门04】彻底掌握BeautifulSoup的CSS选择器 广东职业技术学院 欧浩源 2017-10-21 1、引言 目前&#xff0c;除了官方文档之外&#xff0c;市面上及网络详细介绍BeautifulSoup使用的技术书籍和博客软文并不多&#xff0c;而在这仅有的资料中介绍CSS选择器的少之又少。…