什么是 Class,Calss 的作用
ES6 的 class 可以看作是一个语法糖,它的绝大部分功能 ES5 都可以做到,新的 class 写法只是让对象原型的写法更加清晰、更像面向对象编程的语法
ES6 怎么写 Class
//定义类
class Point { constructor(x,y)
{
//构造方法
this.x = x;
//this 关键字代表实例对象
this.y = y;
} toString() {
return '(' + this.x + ',' + this.y + ')'; } }