JavaScript

JavaScript

Made by DeepSource

Prefer not to use labels that share a name with a variable JS-0121

Bug risk
Minor

Create clearer code by disallowing the bad practice of creating a label that shares a name with a variable that is in scope.

Bad Practice

var x = foo;
function bar() {
x:
  for (;;) {
    break x;
  }
}

Recommended

// The variable that has the same name as the label is not in scope.

function foo() {
  var q = t;
}

function bar() {
q:
  for(;;) {
    break q;
  }
}