Important Notice:

break and continue

break and continue

48 views 1 min read

break and continue Statements:-

हिंदी व्याख्या:

  • break → लूप को पूरी तरह रोक देता है।
  • continue → सिर्फ मौजूदा iteration को skip करके अगले iteration पर चला जाता है।

English Explanation:

  • break → Exits the loop completely.
  • continue → Skips the current iteration and continues with the next

उदाहरण:

JavaScript
 
 for (let i = 1; i <= 10; i++)
    {
           if (i === 5)
            {
               break;         // लूप बंद हो जाएगा
            }
          console.log(i);
    }
Output:-
1 2 3 4

English Explanation:

  • break → Exits the loop completely.
  • continue → Skips the current iteration and continues with the next

continue स्टेटमेंट का उपयोग लूप के मौजूदा iteration को skip करने के लिए किया जाता है। जब continue execute होता है, तो लूप का current round (iteration) रुक जाता है और लूप अगले iteration से शुरू हो जाता है। break की तरह लूप पूरी तरह नहीं रुकता, सिर्फ उस particular iteration को छोड़ दिया जाता है।

English Explanation: The continue statement is used to skip the current iteration of a loop. When continue is executed, the current round of the loop is skipped and the loop continues with the next iteration. Unlike break, it does not terminate the entire loop.

Example:-
for (let i = 1; i <= 8; i++)
{
    if (i === 5)
    {
        continue; // 5 को skip कर दिया जाएगा
    }

    console.log(i);
}
 
Output:-
1 2 3 4 6 7 8

Related Notes