[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Errors/Bad_continue [Back]  [Original]

SyntaxError: continue must be inside loop - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

SyntaxError: continue must be inside loop

JavaScript "continue must be inside loop" continue

SyntaxError: Illegal continue statement: no surrounding iteration statement (V8-based)
SyntaxError: Illegal continue statement: 'label' does not denote an iteration statement (V8-based)
SyntaxError: continue must be inside loop (Firefox)
SyntaxError: 'continue' is only valid inside a loop statement. (Safari)
SyntaxError: Cannot continue to the label 'label' as it is not targeting a loop. (Safari)

SyntaxError.

continue continue SyntaxError: label not found

continue

forEach() return for...of

js
array.forEach((value) => {
  if (value === 5) {
    continue; // SyntaxError: continue must be inside loop
  }
  // value 
});
js
array.forEach((value) => {
  if (value === 5) {
    return;
  }
  // value 
});
js
for (const value of array) {
  if (value === 5) {
    continue;
  }
  // value 
}


Web Proxy Viewer  |  New URL  |  Original Page