> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JavaScript Continue Statement

The `continue` statement is a control flow mechanism used within loop structures to prematurely terminate the execution of the current iteration. When the JavaScript engine encounters a `continue` statement, it bypasses all subsequent statements remaining in the loop's body for that specific iteration and immediately transfers control to the loop's next iteration cycle.

## Syntax

```javascript theme={"dark"}
continue;
continue labelIdentifier;
```

## Execution Mechanics

The exact behavior of the control flow transfer depends on the type of loop enclosing the `continue` statement:

* **`for` loop:** Control jumps directly to the loop's *update expression* (e.g., `i++`). After the update expression executes, the loop's condition is evaluated to determine if the next iteration should proceed.
* **`while` and `do...while` loops:** Control jumps directly to the loop's *condition evaluation*.
* **`for...in` and `for...of` loops:** Control advances to the next enumerable property or iterable value in the sequence.

### Unlabeled `continue`

When used without a label, `continue` applies strictly to the innermost enclosing loop.

```javascript theme={"dark"}
for (let i = 0; i < 4; i++) {
  if (i === 2) {
    continue; // Control jumps to i++
  }
  console.log(i);
}
// Output: 0, 1, 3
```

### Labeled `continue`

JavaScript allows statements to be prefixed with a label identifier. When `continue` is paired with a label, it bypasses the current iteration of the specific loop associated with that label, rather than defaulting to the innermost loop. This is primarily utilized in nested loop architectures.

```javascript theme={"dark"}
outerLoop: for (let i = 0; i < 3; i++) {
  for (let j = 0; j < 3; j++) {
    if (i === 1 && j === 1) {
      continue outerLoop; // Control jumps to i++ of the outer loop
    }
    console.log(`i=${i}, j=${j}`);
  }
}
// Output:
// i=0, j=0
// i=0, j=1
// i=0, j=2
// i=1, j=0
// i=2, j=0
// i=2, j=1
// i=2, j=2
```

## Technical Constraints

1. **Scope Restriction and Function Boundaries:** A `continue` statement must be nested within an iterative statement (`while`, `do...while`, `for`, `for...in`, or `for...of`). Crucially, `continue` cannot cross function boundaries. Using `continue` inside a nested function—such as a callback passed to `.forEach()`, `.map()`, or `setTimeout()`—will throw a `SyntaxError`, even if that function is physically defined or executed inside a loop.

```javascript theme={"dark"}
for (let i = 0; i < 3; i++) {
  [1, 2].forEach(num => {
    if (num === 1) {
      continue; // Throws SyntaxError: Illegal continue statement
    }
  });
}
```

2. **Automatic Semicolon Insertion (ASI):** The `continue` statement is subject to JavaScript's ASI rules. No line terminator (line break) is permitted between the `continue` keyword and its target `labelIdentifier`. If a line break exists, the engine will automatically insert a semicolon after `continue`. This does not throw a `SyntaxError`, but it creates a logical error by executing an unlabeled `continue` and rendering the subsequent label an unreachable expression statement.

```javascript theme={"dark"}
// Logical error due to ASI
continue 
  targetLabel; 

// The engine parses the above as syntactically valid but logically flawed:
// continue;     <- Unlabeled continue executes here
// targetLabel;  <- Unreachable expression statement
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor JavaScript Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
