If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
JavaScript में labeled statement का use break और continue statement के साथ करते हैं , generally JavaScript में labeled statement का use किसी loop को identify करने के लिए किया जाता है।
label_name : statement
label_name JavaScript में reserved keywords को छोड़कर आप कुछ meaningful name दे सकते हैं।
और statement वो while / for loop है जिसे हम label_name के साथ identify कर रहे हैं।
? Note that JavaScript में PHP या C की तरह goto statement नहीं होता है इसलिए labeled statement को आप सिर्फ break या continue statement के साथ ही use कर सकते हैं।
File : continue.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript labeled statement with continue</title>
</head>
<body>
<script>
let x;
mylabel :
for(x=1; x <= 5 ; x++)
{
if(x==3)
{
continue mylabel;
}
document.write(`${x} <br>`);
}
</script>
</body>
</html>
Example में आप देख हैं कि for loop को identify करने के लिए label का नाम mylabel दिया है , उसके बाद loop के अंदर एक particular condition पर continue statement का use किया गया है।
continue statement current loop iteration ( या label के according) को skip कर देता है।
Learn more about continue statement ..
Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)
Get connected with me. :) LinkedIn Twitter Instagram Facebook