1: Câu lệnh break
• Lệnh break dùng để thoát khỏi vòng lặp mà không đi tới điểm cuối
• Khi gặp câu lệnh này trong vòng lặp, chương trình sẽ thoát ra khỏi vòng lặp và chỉ đến câu lệnh liền sau nó
• Nếu nhiều vòng lặp thì break sẽ thoát ra khỏi vòng lặp gần nhất.
• Ngoài ra, break còn được dùng trong cấu trúc lựa chọn switch
Ví dụ:
for(Student s : listStudent){
code block 1
break;
code block 2
}
Khối lệnh 1 vẫn được thực hiện nhưng khối lệnh 2 thì không vì ta đã đặt break để dừng ngay sau khi thực thi khối lệnh 1
2 : Câu lệnh continue
• Lệnh continue để nhảy qua một phần của khối lệnh và bắt đầu dòng tiếp theo.
• Khi gặp lệnh này trong các vòng lặp, chương trình sẽ bỏ qua phần còn lại trong vòng lặp và tiếp tục thực hiện lần lặp tiếp theo.
Ví dụ:
for (var i = 1; i <= 10; i++){
if (i == 4) {
continue;
}
console.log(i);
}
//output: 1 2 3 5 6 7 8 9 10
Vòng lặp đã bỏ qua giá trị i =4
30 comments On Tìm hiểu về lệnh break và continue trong Javascript
I’m not that much of a online reader to be honest but your blogs really nice, keep it up! I’ll go ahead and bookmark your site to come back later. All the best
You actually make it appear really easy together with your presentation however I find this topic to be actually one thing which I believe I would never understand. It sort of feels too complex and very wide for me. I’m looking ahead on your next post, I’ll attempt to get the hold of it!
I enjoy you because of each of your labor on this web site. My niece really likes engaging in research and it is easy to understand why. Most of us know all of the dynamic form you give powerful tips and hints through your website and even inspire response from others about this article while our own girl is certainly being taught a whole lot. Take pleasure in the rest of the year. You have been performing a tremendous job.
Keep working ,terrific job!
hi!,I like your writing so much! share we communicate more about your post on AOL? I require an expert on this area to solve my problem. Maybe that’s you! Looking forward to see you.
I enjoy you because of each of your work on this website. My daughter take interest in managing research and it’s really simple to grasp why. All of us learn all about the compelling manner you make important techniques on this website and increase participation from some other people on this subject matter then our favorite simple princess is actually studying a great deal. Take advantage of the rest of the year. You’re the one performing a wonderful job.
fantástico este conteúdo. Gostei bastante. Aproveitem e vejam este site. informações, novidades e muito mais. Não deixem de acessar para se informar mais. Obrigado a todos e até mais. 🙂
Hello, you used to write great, but the last few posts have been kinda boring… I miss your great writings. Past few posts are just a bit out of track! come on!
hi!,I really like your writing so a lot! proportion we keep up a correspondence extra about your post on AOL? I need a specialist in this house to unravel my problem. Maybe that’s you! Looking ahead to see you.
Great post, I think website owners should acquire a lot from this web blog its really user friendly.
Hey just wanted to give you a quick heads up. The words in your content seem to be running off the screen in Internet explorer. I’m not sure if this is a formatting issue or something to do with web browser compatibility but I thought I’d post to let you know. The style and design look great though! Hope you get the problem solved soon. Kudos
I keep listening to the news bulletin lecture about getting free online grant applications so I have been looking around for the best site to get one. Could you tell me please, where could i get some?
You could definitely see your skills in the work you write. The sector hopes for even more passionate writers such as you who aren’t afraid to mention how they believe. Always follow your heart.
I would like to thank you for the efforts you have put in writing this website. I am hoping the same high-grade website post from you in the upcoming also. Actually your creative writing abilities has inspired me to get my own site now. Actually the blogging is spreading its wings fast. Your write up is a great example of it.
Pretty nice post. I just stumbled upon your blog and wished to say that I’ve really enjoyed browsing your blog posts. In any case I’ll be subscribing to your rss feed and I hope you write again soon!
I regard something really interesting about your web blog so I saved to my bookmarks.
hello!,I really like your writing very much! percentage we keep up a correspondence extra about your post on AOL? I require a specialist in this area to unravel my problem. Maybe that is you! Taking a look forward to see you.
Hi, i feel that i saw you visited my blog so i got here to “return the prefer”.I am trying to in finding issues to enhance my website!I suppose its good enough to make use of some of your concepts!!
Hello. Great job. I did not anticipate this. This is a remarkable story. Thanks!
fascinate este conteúdo. Gostei bastante. Aproveitem e vejam este site. informações, novidades e muito mais. Não deixem de acessar para descobrir mais. Obrigado a todos e até mais. 🙂
Hello. remarkable job. I did not expect this. This is a impressive story. Thanks!
As a Newbie, I am constantly exploring online for articles that can aid me. Thank you
Oh my goodness! an incredible article dude. Thanks Nevertheless I’m experiencing subject with ur rss . Don’t know why Unable to subscribe to it. Is there anybody getting equivalent rss downside? Anybody who is aware of kindly respond. Thnkx
Absolutely pent content material, thank you for information. “The last time I saw him he was walking down Lover’s Lane holding his own hand.” by Fred Allen.
There are actually numerous details like that to take into consideration. That could be a great level to convey up. I offer the ideas above as common inspiration however clearly there are questions just like the one you convey up the place the most important factor might be working in trustworthy good faith. I don?t know if best practices have emerged around issues like that, but I’m positive that your job is clearly recognized as a fair game. Each girls and boys feel the impression of just a moment’s pleasure, for the remainder of their lives.
Very interesting information!Perfect just what I was searching for!
You made some decent points there. I did a search on the issue and found most individuals will agree with your website.
I reckon something genuinely special in this web site.
Heya i am for the primary time here. I came across this board and I find It truly useful & it helped me out a lot. I am hoping to present one thing back and aid others like you aided me.
Real great information can be found on site. “The quality of an organization can never exceed the quality of the minds that make it up.” by Harold R. McAlindon.
Sliding Sidebar
Facebook