Regardless of how charming and elegant it may look when just a silent p ass of a mouse
pointer turns up a sub-menu , there is a danger in doing that. Consider, for example,
that you hide some vital co ntent and make it accessible to your visitor only th rough
hoveringāif the visitor uses a touch screen, he/she will not be able to access it.
Fortunately, thereās a third language called JavaScript, which is responsible for mak-
ing things happen . This makes it a real program ming language as opposed to HTML
and CSS, which are formatting and style-sheet languages, r espectively. We say that
JavaScript deļ¬n es the b ehavior of a web page. Pages equipped with appropriate
JavaScript code can become responsive and intelligent. They can, for example, check
if someone has ļ¬lled out a f orm correctly and let visitors know if they left out neces-
sary information or if they provided information in the wrong form. For example, if
they entered a no n-numeric character for the day of the month, or a date in the future
or too-distant past for the date of birth, which obviou sly cannot pass as a birth day of
a living person.
Although JavaScript is a full-ļ¬edged programming lang uage and you will have no
choice but to learn some basic programming skills, that doesnāt mean it is impossible
to use. All in all, progr ams written in JavaScript are usually much shorter than many
application s you are using in your everyday work, such as text processors or digital
photo-processing software.
By th e way, do you know how to put a chicken in a fridge in three steps?
Mike: First, open the fridge, second, put the chicken inside, and third, close the fridge.
Professor: Right. What about a ļ¬sh in fo ur steps? How do you do that?
Mike: Open the fridge, take the chicken out, put the ļ¬sh in, close the fridge.
Professor: Brilliant! Thatās a joke, all right, but it conveys an extremely importan t
concept. Let me write the instructions down for you:
Open fridge.
Take chicken out.
Put ļ¬sh in.
Close fr idge.
In computer science, such a list of instructions that need to be followed in or der to
carry out a job is called an algorithm. An algorithm is usually written eith er in plain
English or in a so- called pseudo la nguage, which a computer does not understand. If
you want a computer to understand and execute your instructions, you must code these
instructions in a spec iļ¬c computer lan guage. Such a set of executable instructions is
called a computer program.
Although the computer will always obey the order in which your instructions are
listed, the order itself is not always important. If only the ļ¬na l state is important, you
may want, for example, to ļ¬rst put the ļ¬sh in the fridge (if the fridge is big enough to
hold both animals for some time) and only then ta ke the chicken out. But you cannot,
by any means, take the chicken out of the fridge before op ening the frid ge doors. That
is physically impossible.
106 Meeting 6. Behavior