【发布时间】:2016-03-19 09:59:55
【问题描述】:
下面的语法,
class Polygon {
constructor(height, width) {
this.height = height;
this.width = width;
}
}
var Polygon = class {
constructor(height, width) {
this.height = height;
this.width = width;
}
};
var Polygon = class Polygon {
constructor(height, width) {
this.height = height;
this.width = width;
}
};
--
chrome 和 firefox 都不支持。
SyntaxError: Unexpected token class(…)
chrome 版本安装47.0.2526.80 m
已安装firefox版本44.0a2 (2015-12-12)
支持class 和extends 关键字的浏览器版本是什么?
【问题讨论】:
-
为什么不使用受支持的东西,
function Polygon。 -
@SpencerWieczorek 基于类的范式看起来更容易(接近现实世界)构建抽象
-
我认为您需要开启严格模式才能在 Chrome 上运行。
标签: javascript google-chrome firefox browser ecmascript-6