-1
Using label in for
let str = '';
loop1:
for (let i = 0; i < 5; i ++) {
if (i === 1) {
continue loop1;
}
str = str + i;
}
console.log(str);
Not using label on for
let str = '';
for (let i = 0; i < 5; i ++) {
if (i != 1) {
str = str + i;
}
}
console.log(str);
In the two examples both codes do the same thing use one or the other will return the same result, in this example there is some advantage in usinglo, because in my view when making use of it the code gets longer and if the program is extended it will make it difficult to read the code. Not only in these simple examples, but in other cases what are the advantages in using it. I know other languages that have in their entrails the label and goto
inplementados and they are the same as Javascript? (since Javascript does not have the command goto
, but the command continue
kind of "replaces" him).
This answers your question? What is a C label?
– Piovezan