Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. JavaScript
  3. Reference
  4. JavaScript error reference
  5. SyntaxError: label not found

SyntaxError: label not found

The JavaScript exception "label not found" occurs when abreak orcontinue statement references a label that does not exist on any statement that contains thebreak orcontinue statement.

Message

SyntaxError: Undefined label 'label' (V8-based)SyntaxError: label not found (Firefox)SyntaxError: Cannot use the undeclared label 'label'. (Safari)

Error type

SyntaxError.

What went wrong?

In JavaScript,labels are very limited: you can only use them withbreak andcontinue statements, and you can only jump to them from a statement contained within the labeled statement. You cannot jump to this label from anywhere in the program.

Examples

Unsyntactic jump

You cannot use labels as if they aregoto.

js
start: console.log("Hello, world!");console.log("Do it again");break start;

Instead, you can only use labels to enhance the normal semantics ofbreak andcontinue statements.

js
start: {  console.log("Hello, world!");  if (Math.random() > 0.5) {    break start;  }  console.log("Maybe I'm logged");}

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp