ruanyf / es6tutorial

《ECMAScript 6入门》是一本开源的 JavaScript 语言教程,全面介绍 ECMAScript 6 新增的语法特性。

Home Page:http://es6.ruanyifeng.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

21类的基本语法,类和构造

keduhoutian opened this issue · comments

原文:
class Point { constructor() { // ... } toString() { // ... } }
// 等同于
Point.prototype = { constructor() {}, toString() {} }

这里感觉不能完全这么说?一般构造函数是下面这样吗?
Point.prototype = { constructor:Point, toString() {} }
Point.prototype.constructor === Point

这里只是说明,类的定义等价于原型,不是给出精确的实现。