Break and Continue are two reserved keywords in JavaScript that help us when trying to ‘get out’ of a loop, and we’ll cover both in this tutorial.

Break, as the name suggests, breaks out of a loop at any given point, and Continue just tells the loop to ‘skip’ this particular iteration and carries on with the next one.

As always, if you have any questions, ask away :).


========== JavaScript for Beginners Playlist ==========

========== CSS for Beginners Playlist ==========

========== HTML for Beginners Playlist ==========

========== The Net Ninja ============

For more front-end development tutorials & to black-belt your coding skills, head over to – or

========== Social Links ==========

Twitter – @TheNetNinja –


  1. It's easy to understand all these Javascript rules but hard to understand the practical use of all these codes in web development. it would be so kind of you if you explain the actual use of these codes at the same time.

  2. If anyone is still confused by what "continue" does, copy and execute this code in console and it will be clearer.

    var myLoop = document.getElementsByTagName("p");

    for (i = 1; i <= myLoop.length; i++) {

    if (i === 5 || i === 3) {
    console.log("Restart loop when equal " + i);
    console.log("this is number " + i);

    if(i === 7) {
    console.log("loop ended successfully");

  3. Hey mate, quick question for "while, for, break & continue" – can you give an example on where can I possibly use this codes on a certain project? I.e. how or why would I use this when creating a website or something else. JS is daunting seriously. Lol.


Please enter your comment!
Please enter your name here