[javascript-dev] Inheritance...
Stephen Lumenta
lfanele at gmail.com
Sun Dec 2 14:21:13 MST 2007
- Next message: [javascript-dev] array of newobject of type "Number Box"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
I think I'm going cracy. I wanted to write my own objects, but for some reason I can't get inheritance to work in js. I've read about javascript-inheritance on the web before and boiled it down to a simple example, but when you run the code i always get an x undefined...
Is there something obvious i am missing?
Thanks a lot, Stephen
//inheritance revisited
autowatch = 1;
var sub = new Subclass();
bang();
function bang() {
post("inherited x: "+sub.x+"
");
// this should print 244 right?
}
// my SuperClass
function Superclass() {
this.x = 244;
}
// SubClass inherits from SuperClass ?
function Subclass(){
}
Subclass.prototype = new Superclass();
- Next message: [javascript-dev] array of newobject of type "Number Box"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
