From 911dd3404a663e6d9f064ccd16cad25c8c9abab7 Mon Sep 17 00:00:00 2001 From: ruanyf Date: Thu, 12 Oct 2017 09:59:24 +0800 Subject: [PATCH] =?UTF-8?q?docs(class-extends):=20=E5=AD=90=E7=B1=BB?= =?UTF-8?q?=E7=BB=A7=E6=89=BF=E7=88=B6=E7=B1=BB=E7=9A=84=E9=9D=99=E6=80=81?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/class-extends.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/class-extends.md b/docs/class-extends.md index 02b36ee..ead4ea8 100644 --- a/docs/class-extends.md +++ b/docs/class-extends.md @@ -92,6 +92,23 @@ cp instanceof Point // true 上面代码中,实例对象`cp`同时是`ColorPoint`和`Point`两个类的实例,这与 ES5 的行为完全一致。 +最后,父类的静态方法,也会被子类继承。 + +```javascript +class A { + static hello() { + console.log('hello world'); + } +} + +class B extends A { +} + +B.hello() // hello world +``` + +上面代码中,`hello()`是`A`类的静态方法,`B`继承`A`,也继承了`A`的静态方法。 + ## Object.getPrototypeOf() `Object.getPrototypeOf`方法可以用来从子类上获取父类。