You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class A {
name: String = 'test A';
constructor() {
console.log(this.name);
}
}
class B extends A {
name: String = 'test B'
}
new B(); // 'test A'
It will return 'test A', but 'test B' is more obvious output for this code. And also it is very handy to have an ability to override property default value in subclasses.
It cam be easily achieved, if implicit super() call on B will be made after property assignment, just compile to this:
Please see following:
It will return 'test A', but 'test B' is more obvious output for this code. And also it is very handy to have an ability to override property default value in subclasses.
It cam be easily achieved, if implicit super() call on B will be made after property assignment, just compile to this:
instead of this:
You can see example here: http://bit.ly/1cjaMeJ
The text was updated successfully, but these errors were encountered: