24 lines
419 B
Plaintext
24 lines
419 B
Plaintext
![]() |
Labels are not commonly used, and many developers do not understand how they work. Moreover, their usage makes the control flow harder to follow, which reduces the code's readability.
|
|||
|
|
|||
|
== Noncompliant Code Example
|
|||
|
|
|||
|
----
|
|||
|
myLabel: {
|
|||
|
let x = doSomething();
|
|||
|
if (x > 0) {
|
|||
|
break myLabel;
|
|||
|
}
|
|||
|
doSomethingElse();
|
|||
|
}
|
|||
|
----
|
|||
|
|
|||
|
== Compliant Solution
|
|||
|
|
|||
|
----
|
|||
|
let x = doSomething();
|
|||
|
if (x <= 0) {
|
|||
|
doSomethingElse();
|
|||
|
}
|
|||
|
----
|
|||
|
|