A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Label_not_found below:

SyntaxError: label not found - JavaScript

SyntaxError: label not found

The JavaScript exception "label not found" occurs when a break or continue statement references a label that does not exist on any statement that contains the break or continue 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 with break and continue 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 are goto.

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

Instead, you can only use labels to enhance the normal semantics of break and continue statements.

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4