Exercises 1: JavaScript
Manuel Serrano
Inria Sophia-Antipolis Méditerranée
Manuel.Serrano@inria.fr
http://www.inria.fr/indes/Manuel.Serrano
Basic string manipulations
Write a function that escapes
<" and ">
for HTML. Without using regular expressions:
JavaScript, client-side DOM
Write a one-line HTML page. When the mouse is over a letter of the displayed word, that letter is displayed
upcased
.
run
Write a JavaScript programs that generates the solution of the previous question. To generate the file, either use:
% hop -p 8888 upcase.js % hopc upcase.js -- -library hopwidget && a.out % node upcase.js
Write a second version which uses a CSS rule.
Note:
in an event listener, the pseudo variable
this
denotes the object owning the listener.
Note:
the client side function
el.innerHTML=expr
replaces the content of an element with a new HTML subtree.
</exercise>
Lists
In JavaScript define the following list API.
cons
car
set-car!
and
set-cdr!
Implement the API using objects and prototypes.
Implement the API using only functions.