Skip to content

Commit 25cc217

Browse files
committed
docs(class-extends): fix super() ruanyf#657
1 parent 31bef7b commit 25cc217

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/class-extends.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ColorPoint extends Point {
2929

3030
上面代码中,`constructor`方法和`toString`方法之中,都出现了`super`关键字,它在这里表示父类的构造函数,用来新建父类的`this`对象。
3131

32-
子类必须在`constructor`方法中调用`super`方法,否则新建实例时会报错。这是因为子类没有自己的`this`对象,而是继承父类的`this`对象,然后对其进行加工。如果不调用`super`方法,子类就得不到`this`对象。
32+
子类必须在`constructor`方法中调用`super`方法,否则新建实例时会报错。这是因为子类自己的`this`对象,必须先通过父类的构造函数完成塑造,得到与父类同样的实例属性和方法,然后再对其进行加工,加上子类自己的实例属性和方法。如果不调用`super`方法,子类就得不到`this`对象。
3333

3434
```javascript
3535
class Point { /* ... */ }

0 commit comments

Comments
 (0)