Javascript Labeled Statements

Introduction

We can label statements for later use with the following syntax:

label: statement 

Here's an example:

start: for (let i = 0; i < count; i++) { 
   console.log(i); 
} 

In this example, the label start can be referenced later by using the break or continue statement.

Labeled statements are typically used with nested loops.




PreviousNext

Related