JavaScript continue Statement In Hindi

📔 : Java Script 🔗

JavaScript में Continue का use किसी दी गयी condition के according current loop iteration को skip करने के लिए किया जाता है। और skip करने के बाद Loop next iteration से Start हो जाता है। simply हम कह सकते हैं कि JavaScript में Continue का use हम वहाँ करते हैं जब हमें किसी condition पर loop execution को skip करना हो।

? continue statement loop execution को terminate नहीं करता है current iteration को skip करता है -

  • while loop में continue statement current loop execution skip करके वापस condition पर जाता है।

  • for / for in / for of loop में continue statement current  loop execution skip करके वापस updated iteration पर जाता है। 

  • जबकि if else में current if / else को skip (बाहर) करता है।

JavaScript continue Statement Syntax

continue [label]; 

continue एक Optional parameter accept करता है , label उस loop को identify करता है जिसका current execution skip करना हो। by default यह current loop का ही execution skip करता है according to condition .

Learn more about labeled statement . . .

JavaScript continue Statement Example

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JavaScript continue Statement </title> </head> <body> <script> let x; for(x=1; x <= 5 ; x++) { if(x==3) { continue; } document.write(`${x} <br>`); } </script> </body> </html>

Example में आप देख सकते हैं कि x की value 3 होते ही वो level skip होकर next iteration start हो गयी।

? well , JavaScript में continue statement PHP से थोड़ा अलग होता है क्योंकि PHP में हम continue statement के लिए optional parameter की value सिर्फ integer ही दे सकते हैं , जबकि JavaScript में continue statement में optional parameter की value हम किसी loop (for या while loop ) को identify करने के लिए define किये गए label का name provide कराते हैं। जिसे Labeled Statement भी कहते हैं।

JavaScript continue with label

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JavaScript continue Statement </title> </head> <body> <script> let x; forloop_label : for(x=1; x <= 5 ; x++) { if(x==3) { continue forloop_label; } document.write(`${x} <br>`); } </script> </body> </htmll>

Output :

1
2
4
5

Example में आप देख हैं कि for loop को identify करने के लिए label का नाम forloop_label दिया है , उसके बाद loop के अंदर एक particular condition पर continue के बाद उस label का name दिया गया है ।

Related Topics :

Rahul Kumar

Rahul Kumar

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

b2eprogrammers