9 of 264 menu

The break Statement

The break statement performs a forced exit from a loop. It can terminate any loops: for, for-of, for-in, while.

Syntax

break;

Example

Let's determine if the array contains the number 3. If it does - output '+++' to the console and exit the loop:

let arr = [1, 2, 3, 4, 5]; for (let elem of arr) { if (elem == 3) { console.log('+++'); break; // exit the loop } }

See also

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline