JavaScript Label Statement

JavaScript Label Statement

In my other article where I share about break and continue statements, there might seem to be something missing or incomplete.

In my other article where I share about break and continue statements, there might seem to be something missing or incomplete.

If you notice, those statements can only be used in a loop or rather, can only be used by the innermost loop in nested loops. So, does that mean the two statements cannot target the outer loop? Can’t they be used to break out of the parent loop or skip an iteration of the parent loop instead of the loop they are in?

JavaScript has a relatively unknown functionality which allows us to identify a loop. This identification can allow the two statements to target any loop in nested loops. This is the label statement which allows us to identify a statement which can then be referred to.

It can be applied to any statements. Once the labeling is done, it acts as an identifier that can be referred to elsewhere in the program.

To label JavaScript statements, simply precede the statements with a label name and a colon, and then followed by the statements themselves.




  • label — Naming as an identifier
  • statement(s) — Any JavaScript statement


What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Hire Dedicated JavaScript Developers -Hire JavaScript Developers

Hire dedicated JavaScript Developers who are proficient in AngularJS, ReactJS, NodeJS, & VueJS frameworks. Get flexible hiring models as per your business requirements.

What is JavaScript - Stackfindover - Blog

What is PHP: - Who invented PHP, how it works, answers to all such questions about PHP, and much other information, you are going to

JavaScript Shopping Cart - Javascript Project for Beginners

JavaScript Shopping Cart - javascript shopping cart tutorial for beginnersBuy me a coffee 🍺 Code: https://bit....

The essential JavaScript concepts that you should understand

The essential JavaScript concepts that you should understand - For successful developing and to pass a work interview

JavaScript compound assignment operators

We use assignment operator in JavaScript to store values in a variable. Read more...