I have two very simple classes in my Javascript code:
class Renderable{
toHTML(){
return '';
}
}
class Intro extends Renderable{
constructor(title, pretitle, backgroundImage){
debugger;
this.title = title;
this.pretitle = pretitle;
this.backgroundImage = backgroundImage;
}
[...]
}
The code is in order this way, so there shouldn't be any hoisting issues. However, when I load my web page I get the following error:
ReferenceError: Cannot access uninitialized variable.
at the line this.title = title;
in the constructor. When I break on the debugger, I see that this
is indeed undefined
. What am I doing wrong?