Branching Statements


Branching statements enable you to make choices. JavaScript has two branching statements: if and switch . The if statement is so important that we've already seen it at work both in this and the previous chapter; we'll take a look at it in depth here.

This statement enables you to select which code to execute depending on whether a certain test condition (usually involving the comparison operators we've already seen, like this: votesForPizza > votesForHamburgers ). In fact, the if statement is so important in JavaScript that the other branching statement, the switch statement, is really just a modified if statement that you use when you want to handle multiple test conditions. We'll see both of them here, starting with the if statement.



Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net