JavaScript labels


/ Published in: JavaScript
Save to your folder(s)

Just some pseudo-code notes about using labels with `break` and `continue` statements.


Copy this code and paste it in your HTML
  1. outer_loop:
  2. while(outer_condition)
  3. {
  4. //some statements
  5. while(inner_condition)
  6. {
  7. //some statements
  8. if(skip_the_rest_of_inner) continue;
  9. if(exit_inner_and_skip_the_rest_of_outer) continue outer_loop;
  10. if(exit_inner_loop) break;
  11. if(exit_outer_loop) break outer_loop;
  12. //statements to skip
  13. }
  14. //statements to skip
  15. }
  16.  
  17. statements_block:
  18. {
  19. //some statements
  20. if(skip_remaining_statements) break statements_block;
  21. //statements to skip
  22. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.