Posted by: ทวี | มีนาคม 20, 2007

Object Oriented Programming using JavaScript

Subclasses and Superclasses :

<script language="javascript" contenttype="text/javascript">
<!--

function superTest() {
return “superTest”
}

function subTest() {
return “subTest”
}

function superClass() {
this.supertest = superTest; //attach method superTest
}

function subClass() {
this.inheritFrom = superClass;
this.inheritFrom();
this.subtest = subTest; //attach method subtest
}

newClass = new subClass();
document.write(newClass.subtest()); //yields “subTest”
document.write(”<br/>”);
document.write(newClass.supertest()); //yields “superTest”
//–>
</script>


Leave a response

Your response:

หมวดหมู่