1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 18:32:22 +00:00

Update class.md

添加了使用类的简单说明
This commit is contained in:
xufanglu 2014-05-01 23:33:05 +08:00
parent 69fc529aa6
commit 8e077e4956

View File

@ -6,6 +6,7 @@ ES6引入了Class这个概念可以定义class作为对象的模
```javascript
//定义类
class Point {
constructor(x, y) {
@ -19,6 +20,10 @@ class Point {
}
//使用类
var point = new Point(2,3);
point.toString(); //(2, 3)
```
上面代码定义了一个class类可以看到里面有一个constructor函数这就是构造函数。而this关键字则代表实例对象。