I
ingoweiss
Hi,
I am having trouble passing parameters of a Javascript subclass
constructor through to it's superclass constructor.
I am trying all sorts of things, including the below, but nothing
worked so far.
Thanks for any help!
function Base(a)
{
this.a = a;
}
function Derived(a)
{
this.prototype.constructor.call(a);
}
Derived.prototype = new Base();
Derived.prototype.constructor = Derived;
var derived = new Derived("hello");
//a should be "hello" now, but it is undefined:
window.alert(derived.a)
I am having trouble passing parameters of a Javascript subclass
constructor through to it's superclass constructor.
I am trying all sorts of things, including the below, but nothing
worked so far.
Thanks for any help!
function Base(a)
{
this.a = a;
}
function Derived(a)
{
this.prototype.constructor.call(a);
}
Derived.prototype = new Base();
Derived.prototype.constructor = Derived;
var derived = new Derived("hello");
//a should be "hello" now, but it is undefined:
window.alert(derived.a)