javascript/base.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Base class for JavaScript</title>
<script type="text/javascript" src="base.js"></script>
</head>
<body>
<h1>Base class for JavaScript</h1>
<script type="text/javascript">
// TEST
var object = new Base;
object.extend({
value: "some data",
method: function() {
document.writeln("Hello World!");
}
});
object.method();
// ==> Hello World!
// TEST
var object = new Base;
object.method = function() {
document.writeln("Hello World!");
};
object.extend({
method: function() {
// call the "super" method
this.base();
// add some code
document.writeln("Hello again!");
}
});
object.method();
// ==> Hello World!
// ==> Hello again!
</script>
</body>
</html>