循环中 break 与 continue 的区别
2016-02-20 17:19
411 查看
break语句:break语句可用于跳出循环,break语句跳出循环后,会继续执行该循环之后的代码(如果有的话)。
continue语句:continue语句中断循环,如果出现了指定的条件,然后继续循环中的下一个迭代。
continue语句:continue语句中断循环,如果出现了指定的条件,然后继续循环中的下一个迭代。
<span style="white-space:pre"> </span>//break语句:break语句可用于跳出循环,break语句跳出循环后,会继续执行该循环之后的代码(如果有的话)。例: for (var i = 0;i<10 ;i++ ) { if(i == 3){ break; //break直接结束循环 } document.write("break语句结果:"+ i + "<br/>"); } <pre name="code" class="javascript"><span style="white-space:pre"> </span>document.write("<br/><br/>-----------------------------华丽丽的分隔符----------------------------------------<br/><br/>")
<span style="white-space:pre"> </span>//continue语句:continue语句中断循环,如果出现了指定的条件,然后继续循环中的下一个迭代。例: for (var i = 0;i<10 ;i++ ) { if(i == 3){ continue;//continue跳过当然,继续循环 } document.write("continue语句结果:"+ i + "<br/>"); }输出结果:
相关文章推荐
- 分享一款很好的视频处理软件 会声会影X8(huishenghuiyingx8-trial_x64)
- UITableView
- CodeForces 622A Infinite Sequence
- EasyUI系列学习(九)-Panel(面板)
- uiautomatorviewer获取当前屏幕中的各个元素信息包括类名
- 1041. Be Unique (20)
- 【UER #1】跳蚤OS(Trie)
- php中$_REQUEST、$_POST、$_GET的区别和联系小结
- 求php中的request详细用法
- CodeForces 626A Robot Sequence
- RequireJS 与 SeaJS 的异同
- the behavior of the UICollectionViewFlowLayout is not defined because:
- POJ 2299 Ultra-QuickSort(树状数组+离散化)
- 制作 Nine-Patch 图片
- UIScrollView
- iOS UIView及其子控件的常用设置
- 以访客至上的网页设计(三)
- iOS开发-------3D Touch之Peek,Pop,UIPreviewAction
- POJ 3481 Double Queue
- Android:requestFeature() must be called before adding content