{"id":93,"date":"2026-05-01T15:29:32","date_gmt":"2026-05-01T15:29:32","guid":{"rendered":"https:\/\/gigz.pk\/javascript\/?post_type=lesson&#038;p=93"},"modified":"2026-05-01T15:29:33","modified_gmt":"2026-05-01T15:29:33","slug":"break-and-continue","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/javascript\/?lesson=break-and-continue","title":{"rendered":"Break and continue"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">JavaScript provides control statements that help manage how loops and conditions behave. Two important statements used inside loops are break and continue. These statements allow developers to control the flow of execution more efficiently.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding Break Statement<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The break statement is used to stop a loop completely when a specific condition is met. Once break is executed, the loop ends immediately and the program continues with the next part of the code.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example of Break<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>for (let i = 1; i &lt;= 10; i++) {<br>  if (i === 5) {<br>    break;<br>  }<br>  console.log(i);<br>}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this example, the loop stops when the value of i becomes 5. The output will display numbers from 1 to 4 only.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding Continue Statement<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The continue statement is used to skip a specific iteration of a loop. Instead of stopping the loop, it moves to the next iteration.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example of Continue<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>for (let i = 1; i &lt;= 5; i++) {<br>  if (i === 3) {<br>    continue;<br>  }<br>  console.log(i);<br>}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this example, when i is 3, the loop skips that iteration. The output will display 1, 2, 4, and 5.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Key Differences Between Break and Continue<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Break stops the entire loop execution<br>Continue skips only one iteration and continues the loop<br>Break exits the loop completely<br>Continue keeps the loop running<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">When to Use Break and Continue<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use break when you want to stop a loop early based on a condition<br>Use continue when you want to skip certain values but continue looping<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Practical Use Cases<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Stopping a search when a result is found<br>Skipping invalid or unwanted data during processing<br>Improving performance by avoiding unnecessary iterations<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Break and continue statements are essential for controlling loops in JavaScript. They help make code cleaner, more efficient, and easier to manage.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/javascript\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">JavaScript Fundamentals (Beginner Level) > Loops > break and continue<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1777649341939\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"menu_order":0,"template":"","class_list":["post-93","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Break and continue - Learn JavaScript with GIGZ.PK<\/title>\n<meta name=\"description\" content=\"Learn how to use break and continue in JavaScript to control loops, skip iterations, and improve code efficiency easily\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/javascript\/?lesson=break-and-continue\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Break and continue - Learn JavaScript with GIGZ.PK\" \/>\n<meta property=\"og:description\" content=\"Learn how to use break and continue in JavaScript to control loops, skip iterations, and improve code efficiency easily\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/javascript\/?lesson=break-and-continue\" \/>\n<meta property=\"og:site_name\" content=\"Learn JavaScript with GIGZ.PK\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-01T15:29:33+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?lesson=break-and-continue\",\"url\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?lesson=break-and-continue\",\"name\":\"Break and continue - Learn JavaScript with GIGZ.PK\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/#website\"},\"datePublished\":\"2026-05-01T15:29:32+00:00\",\"dateModified\":\"2026-05-01T15:29:33+00:00\",\"description\":\"Learn how to use break and continue in JavaScript to control loops, skip iterations, and improve code efficiency easily\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?lesson=break-and-continue#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?lesson=break-and-continue\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?lesson=break-and-continue#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/javascript\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript Fundamentals (Beginner Level) > Loops > break and continue\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/\",\"name\":\"Learn JavaScript with GIGZ.PK\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Break and continue - Learn JavaScript with GIGZ.PK","description":"Learn how to use break and continue in JavaScript to control loops, skip iterations, and improve code efficiency easily","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gigz.pk\/javascript\/?lesson=break-and-continue","og_locale":"en_US","og_type":"article","og_title":"Break and continue - Learn JavaScript with GIGZ.PK","og_description":"Learn how to use break and continue in JavaScript to control loops, skip iterations, and improve code efficiency easily","og_url":"https:\/\/gigz.pk\/javascript\/?lesson=break-and-continue","og_site_name":"Learn JavaScript with GIGZ.PK","article_modified_time":"2026-05-01T15:29:33+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/javascript\/?lesson=break-and-continue","url":"https:\/\/gigz.pk\/javascript\/?lesson=break-and-continue","name":"Break and continue - Learn JavaScript with GIGZ.PK","isPartOf":{"@id":"https:\/\/gigz.pk\/javascript\/#website"},"datePublished":"2026-05-01T15:29:32+00:00","dateModified":"2026-05-01T15:29:33+00:00","description":"Learn how to use break and continue in JavaScript to control loops, skip iterations, and improve code efficiency easily","breadcrumb":{"@id":"https:\/\/gigz.pk\/javascript\/?lesson=break-and-continue#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/javascript\/?lesson=break-and-continue"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/javascript\/?lesson=break-and-continue#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/javascript"},{"@type":"ListItem","position":2,"name":"JavaScript Fundamentals (Beginner Level) > Loops > break and continue"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/javascript\/#website","url":"https:\/\/gigz.pk\/javascript\/","name":"Learn JavaScript with GIGZ.PK","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/javascript\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/javascript\/index.php?rest_route=\/wp\/v2\/lesson\/93","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/javascript\/index.php?rest_route=\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/javascript\/index.php?rest_route=\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/javascript\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=93"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}