Quiz Number 7

SWE 432, Fall 2009
October 22


  1. What is an event? Give some examples.
    Answer: An event is a notification that something specific has occurred. Examples are completion of loading a document, a mouse click on a form button, etc.
  2. What is an event handler?
    Answer: An event handler is a program (or script, this week) that is executed in response to the occurrence of an event.
  3. Explain the concept of registration and explain one of the two ways that JavaScript handles registration. (Bonus point for explaining both.)
    Answer: Registration is the process of associating an event handler with a particular event. Registration can take place inside a tag by associating JavaScript with an event property. Or, handler functions can be assigned to event properties (in the DOM). Note that in the latter case, it is not possible to pass parameters.
  4. What is a dynamic XHTML document?
    Answer: A dynamic document is a document whose content can be changed after loading via user events.

    The term is also used to describe documents generated "on-the-fly" by web servers (as opposed to simply reading a document out of a file.) This answer is fine for credit, even though it doesn't correspond to what we were discussing last week.

  5. What is the advantage of using the builtin JavaScript array functions such as reverse(), split() and sort() rather than simply writing code which accomplishes these functions?
    Answer: It is always better to (re)use the library functions than to hand craft because a) the library functions are already generally well-tested, and b) your code will be shorter and easier to understand.