Ramin
Ramin

Reputation: 39

Do we have labeled Statements in Typescript similar to what we have in JS?

I found this very interesting that we can break or continue a loop in Javascript. Do we have a similar concept in Typescript (Angular)?

let str = '';

loop1:
for (let i = 0; i < 5; i++) {
  if (i === 1) {
    continue loop1;
  }
  str = str + i;
}

console.log(str);
// expected output: "0234"

Upvotes: 1

Views: 541

Answers (1)

Ramin
Ramin

Reputation: 39

The answer is yes, it is working in typescript. However, it is a JS native statement that is compatible with typescript and is not part of typescript statements.

Upvotes: 1

Related Questions