当前位置:网站首页>js中的break与continue退出
js中的break与continue退出
2022-07-31 05:11:00 【杂乱无章的我】
break与continue语句对循环中的代码进行了更强力的控制。
break与continue语句的不同区别:
break 语句可以立即退出循环,阻止再次反复执行任何代码。
而 continue 语句只是退出当前循环,根据控制表达式还允许继续进行下一次循环。
break退出:
break关键字可以用来退出switch或循环语句,不能在if语句中使用break与continue。
break关键字,会立即停止离它最近的那个循环语句。
continue退出:
continue关键字可以用来跳过当次循环,同样continue也是默认会对离它最近的循环起作用。
continue关键字会用来跳过当次循环。break退出:
break退出:
for(var i=0; i<5; i++){
console.log(i);
if(i == 2){
break;
}
}
输出结果为0;1;2。
continue退出:
continue退出:
for(var i=0; i<5; i++){
if(i==2){
continue;
}
console.log(i);
}
输出结果为0;1;3;4。
边栏推荐
- Several solutions for mysql startup error The server quit without updating PID file
- MySql to create data tables
- Access数据库的查询
- leetcode-829. 连续整数求和(数论)
- The latest MySql installation teaching, very detailed
- [Elastic-Job source code analysis] - job listener
- Access database query
- 闭包(五)----一个常见的循环
- Yuan prospect and four track of the universe
- 13 【代理配置 插槽】
猜你喜欢

mysql password modification method in Linux (pro-test available)

leetcode-每日一题565. 数组嵌套(标记图和并查集)

vulhub靶场学习日记xxe-lab

12 【nextTick 过渡与动画】

局部变量成员变量、引用类型、this,static(第五天)
![[Cloud Native] What should I do if SQL (and stored procedures) run too slowly?](/img/40/be3a30743ee2bc6c82f82ab852f29c.png)
[Cloud Native] What should I do if SQL (and stored procedures) run too slowly?

安装Multisim出现 No software will be installed or removed解决方法

(Crypto必备干货)详细分析目前NFT的几大交易市场
![[uiautomation] Get WeChat friend list (stored in txt)](/img/26/1f3424c5998c52c6e10ced8529012a.png)
[uiautomation] Get WeChat friend list (stored in txt)

vulhub靶场学习日记SickOs1.2
随机推荐
Fragmented NFT (Fractional NFT)
Take you to understand the MySQL isolation level, what happens when two transactions operate on the same row of data at the same time?
碎片化NFT(Fractional NFT)
Install mysqldb in mac10.14
leetcode-每日一题731. 我的日程安排表 II
Regular Expression Basics
带你搞懂MySQL隔离级别,两个事务同时操作同一行数据会怎样?
gin框架学习-Casbin进阶之策略管理API使用方法
Redis:简单实用
C语言 | 获取字符串里逗号间隔的内容
leetcode-438. 找到字符串中所有字母异位词(滑动窗口)
The latest MySql installation teaching, very detailed
let和const命令
MySQL-如何分库分表?一看就懂
数据库 | SQL增删改查基础语法
leetcode-每日一题735. 行星碰撞(栈模拟)
npm WARN config global `--global`, `--local` are deprecated. Use `--location solution
DeFi Token in the project management
npm WARN config global `--global`, `--local` are deprecated. Use `--location解决方案
Three-party login using wallet Metamask based on web3.0