Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2004
    Thanked 0 Times in 0 Posts

    question on break statements

    I am relativly new to programming, and have a question about break statements.

    is there any way to create a break statement that will break you out of more than one loop, not just the one you are currently in?
    or, is there any way to go from one point in a program to another, with having to write a if-else statement?

    also, if i have this: while(ytotal<21 && deci!=s){
    lot's of code....

    if there any way to make the "s" a character, not a variable?

    thanks, 123altoids
    Last edited by 123altoids; 11-07-2004 at 04:52 PM. Reason: forgot to add a quetsion.

  2. #2
    Master Coder
    Join Date
    Feb 2003
    Umeň, Sweden
    Thanked 83 Times in 74 Posts
    Yes. Any kind of statement may have a label. They look like this:
    label: statement
    The label part must be a valid identifier, but it does not share namespace with any other type of identifier. Thus, you may have a label and a variable with the same name. The JavaScript engine will know when you are using the variable and when you are using the label.

    The break statement looks like either of these:
    break label;
    The first one can only be used in loops, and will abruptly terminate the directly enclosing loop or switch statement. The second one may be used inside the label statement with specified label, and will abruptly terminate the statement.
    Last edited by liorean; 11-07-2004 at 05:45 PM.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts