HTML and CSS Reference
Being able to manipulate the Document Object Model (DOM), create animations, and use
a great skill to have. To leverage the power of the user experience fully, however, you need
to provide users with certain website functions only under certain conditions, a concept
top to bottom in the order in which the code was written. This is useful in some cases, but in
most situations in which a dynamic user experience is required, logic needs to be processed
conditionally. Program flow can be conditional, iterative, or behavioral:
■ Conditional program flow is based on evaluating state to make a decision as to which
code should run.
■ Iterative flow is the ability to process lists or collections of information systematically
■ Behavioral flow can be defined as an event or callback in which specific logic should
be applied based on user engagement with the web application or the completion of
Flow can—and almost always will—include a combination of all three.
Another special type of program flow involves exception handling . Exception handling
constructs provide the ability to run specific logic in the case of an error in the program.
Objectives in this chapter:
■ Objective 2.1: Implement program flow
■ Objective 2.2: Raise and handle an event
■ Objective 2.3: Implement exception handling
■ Objective 2.4: Implement a callback
■ Objective 2.5: Create a web worker process