## 静态方法 | |
类相当于实例的原型,所有在类中定义的方法,都会被实例继承。如果在一个方法前,加上`static`关键字,就表示该方法不会被实例继承,而是直接通过类来调用,这就称为“静态方法”。 | |
```javascript | |
class Foo { | |
static classMethod() { | |
return 'hello'; | |
} | |
} | |
Foo.classMethod() // 'hello' | |
var foo = new Foo(); |
ECMAScript 6 入门
连接来自: https://github.com/ruanyf/es6tutorial/search?utf8=%E2%9C%93&q=static