Labeled Blocks in JavaScript


In JavaScript, labeled blocks are a way to label a block of code using an identifier (label). These labels are used in conjunction with statements like "break" and "continue" to control the flow of execution within nested loops or blocks.

Syntax:
       labelName: {
           // Code block or statements
       }


Source Code

HTML Code
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Tutor Joes</title>
</head>
<body>
 
	<script src="js/script.js"></script>
</body>
</html>
To download raw file Click Here

script.js
let groups = [
  ["Ram", "Sam", "Ravi"],
  ["Kumar", "Tiya", "Sundar"],
  ["Rajesh", "Sara", "Rahul"],
];

for(let group of groups)
{
  inner:
  for(let member of group)
  {
    if(member.startsWith('R')){
      console.log("found one starting with R:", member);
      break inner;
    }
  }
}
To download raw file Click Here

List of Programs


JS Practical Questions & Answers


JS Practical Project