HTML and CSS Reference
In-Depth Information
CHAPTER 2
Implement program low
Being able to manipulate the Document Object Model (DOM), create animations, and use
the various application programming interfaces (APIs) provided by the JavaScript library is
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
known as program flow . Without program flow, JavaScript programs would process from
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
and consistently.
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
another task.
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
 
 
Search WWH ::




Custom Search