• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 18. Introduction to JavaScripting > Controlling Your JavaScripts

Controlling Your JavaScripts

Some scripts you write will be simple. They will execute the same way every time, one time per page. If you add a JavaScript to play a sound when users visit your home page, for example, it doesn't need to evaluate any conditions or do anything more than one time. More sophisticated scripts might require that you take different actions under different circumstances. You might also want to repeat the execution of a block of code—perhaps by a set number of times or as long as some condition is TRUE. JavaScript provides constructs for controlling the execution flow of your script based on conditions, as well as for repeating a sequence of operations.

Testing Conditions

JavaScript provides a single type of control statement for making decisions: the if…else statement. To make a decision, you supply an expression that evaluates to TRUE or FALSE; which code is executed depends on what your expression evaluates to.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint