JavaScript Break and Continue
The break
statement “jumps out” of a loop.
The continue
statement “jumps over” one iteration in the loop.
The Break Statement
You have already seen the break
statement used in an earlier chapter of this tutorial. It was used to “jump out” of a switch()
statement.
The break
statement can also be used to jump out of a loop:
Example
for (let i = 0; i < 10; i++) {
if (i === 3) { break; }
text += "The number is " + i + "<br>";
}
In the example above, the break
statement ends the loop (“breaks” the loop) when the loop counter (i) is 3.
The Continue Statement
The continue
statement breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop.
This example skips the value of 3:
Example
for (let i = 0; i < 10; i++) {
if (i === 3) { continue; }
text += "The number is " + i + "<br>";
}
JavaScript Labels
To label JavaScript statements you precede the statements with a label name and a colon:
label:
statements
The break
and the continue
statements are the only JavaScript statements that can “jump out of” a code block.
Syntax:
break labelname; continue labelname;
The continue
statement (with or without a label reference) can only be used to skip one loop iteration.
The break
statement, without a label reference, can only be used to jump out of a loop or a switch.
With a label reference, the break statement can be used to jump out of any code block:
Example
const cars = ["BMW", "Volvo", "Saab", "Ford"];
list: {
text += cars[0] + "<br>";
text += cars[1] + "<br>";
break list;
text += cars[2] + "<br>";
text += cars[3] + "<br>";
}
Note: A code block is a block of code between { and }.
50 Responses
order levofloxacin 500mg without prescription levofloxacin uk
avodart 0.5mg cost avodart 0.5mg pills ondansetron 8mg generic
cost spironolactone order valtrex 1000mg generic cheap fluconazole 100mg
buy ampicillin 500mg purchase bactrim generic erythromycin 250mg us
sildenafil price brand fildena 100mg cost robaxin
sildenafil over the counter aurogra 100mg uk estrace 2mg cost
buy lamictal without prescription order minipress 2mg generic order tretinoin gel for sale
buy tadalafil 20mg generic buy tadalafil 10mg online cheap voltaren 50mg price
order accutane 40mg generic accutane 10mg for sale buy zithromax pill
purchase indocin sale order suprax 100mg generic amoxicillin 500mg pill
cheap cialis for sale cialis brand order viagra pills
order arimidex 1mg generic Buy now viagra viagra pills
tadalafil pas cher acheter 5mg tadalafil viagra 200mg generique
cialis ohne rezept cialis kaufen ohne rezept sildenafil 100mg ohne rezept
accutane 20mg cheap buy generic amoxil 500mg ivermectin 3mg for sale
provigil 100mg price buy generic diamox 250mg acetazolamide 250mg tablet
order doxycycline buy doxycycline 200mg generic cost furosemide 100mg
buy ramipril online cheap buy temovate without prescription brand astelin 10 ml
catapres buy online clonidine 0.1 mg without prescription oral spiriva 9 mcg
buspar uk order buspirone generic ditropan 2.5mg ca
buy fosamax sale brand fosamax 70mg famotidine 20mg us
generic benicar 10mg benicar online acetazolamide us
purchase prograf online order requip online cheap buy ursodiol without prescription
imdur 40mg for sale cost azathioprine 50mg buy micardis 80mg for sale
buy zyban 150 mg online strattera medication brand quetiapine 50mg
purchase molnunat for sale buy cefdinir 300mg order prevacid 15mg generic
purchase zoloft online cheap lexapro 20mg ca order viagra online
buy salbutamol pill us viagra viagra usa
tadalafil 40mg without prescription generic cialis 5mg sildenafil next day
order cialis 5mg pill buy cialis 20mg generic amantadine 100mg cheap
naltrexone 50mg uk order letrozole 2.5mg generic abilify online order
buy generic dapsone 100mg purchase aceon for sale perindopril canada
medroxyprogesterone 10mg uk buy cyproheptadine 4 mg online cyproheptadine 4mg pills
generic provigil order provigil 200mg sale buy ivermectin 3mg
accutane 40mg cheap cheap amoxicillin without prescription prednisone 20mg us
buy nootropil 800 mg pills buy generic sildenafil 100mg buy viagra 100mg generic
azithromycin over the counter prednisolone 10mg uk order neurontin 600mg pill
tadalafil 10mg usa generic cialis 10mg viagra 25mg
order furosemide 100mg for sale doxycycline 200mg for sale hydroxychloroquine 200mg us
cialis 20mg oral purchase betnovate for sale buy anafranil 50mg generic
aralen brand generic baricitinib order olumiant 4mg generic
Good depth 🙂
авиатор игра стратегия
bitcoin pro app
pin up
출장마사지
ErnestEvage
https://xn—-24-7-2nfbpd5dza0bncg0a6al.xn--p1ai
https://xn—24-7-3vebi7a0c8ajhwdyl9mh.xn--p1ai/
https://xn—24-7-4vevhge6enkbeai0a1a5dye2c.xn--p1ai
https://xn—24-7-3vebnd9cxa7amcgy4al.xn--p1ai
https://xn—-24-7-3nfzigf2folbfai2a2a8d2e3c.xn--p1ai
https://xn—24-7-3vebahb3baz2czbsdzdf9b3a4x.xn--p1ai/
https://xn--24-7–3vefjh5cxa7amcku4ap.xn--p1ai
comprar cialis 5 mg cialis 5 mg precio cialis
Loved the photos, i actually like the among %image_title%, perfecto.
https://vash1host.ru
https://hankook1.online
https://cordiant-1.online
https://pirelli1.online
https://yokohama1.online
https://domodedovo2012.ru
https://nokian1.online
https://kupitshin.online
https://testcars.ru
https://kormoran1.online
https://sekup.ru
https://bridgestone2.ru
https://o-dom2.ru
https://prodvizhenie-sait.ru
https://goodyear1.online
https://akita-kennel.ru
https://seo-privat.ru
https://mytop-site.ru
https://toyo1.online
https://tireservice1.online
https://michelin1.online
https://seo-top-site.ru
https://pirelli1.online
ice blazer arctic evo
летняя резина овейшен
BrucePibre
https://tireservice1.online
seo moscow
продвижение сайта поисковая оптимизация реклама
https://seo-top-site.ru
continental conticrosscontact lx2
отзывы ultra grip ice 2
GregoryNuG
https://hankook1.online
продвижение москва
top 10
https://seo-top-site.ru
летняя резина kama
коммерческие шины тунга
Georgedrait
https://michelin1.online
раскрутка яндексе цены сео джамп
сео продвижение сайтов цены
DonaldKat
https://xn—-24-7-3nfzigf2folbfai2a2a8d2e3c.xn--p1ai
https://xn--24-7–3vefjh5cxa7amcku4ap.xn--p1ai
https://xn—24-7-3vebnd9cxa7amcgy4al.xn--p1ai
https://xn—24-7-4vevhge6enkbeai0a1a5dye2c.xn--p1ai
https://xn—-24-7-2nfbpd5dza0bncg0a6al.xn--p1ai
https://xn—24-7-3vebahb3baz2czbsdzdf9b3a4x.xn--p1ai/
https://xn—24-7-3vebi7a0c8ajhwdyl9mh.xn--p1ai/