理解 es6 class 中 constructor 方法 和 super 的作用
首先,ES6 的 class 属于一种“语法糖”,所以只是写法更加优雅,更加像面对对象的编程,其思想和 ES5 是一致的。function Point(x, y) { this.x = x; this.y = y;}Point.prototype.toString = function() { return '(' + this.x + ',' + this.y + ')';}等同于class Point { constructor(x, y) { this.x =
转载
2021-01-14 15:41:37 ·
1170 阅读 ·
0 评论