ES6课程不适用于Chrome 47

Vah*_*iri 6 javascript google-chrome ecmascript-6

自版本42以来,Google Chrome声称支持ES6类,但是Uncaught SyntaxError: Unexpected token class(…)当我在控制台中运行下面的简单代码时,它会提供:

class Polygon {
  constructor(height, width) {
    this.name = 'Polygon';
    this.height = height;
    this.width = width;
  }
Run Code Online (Sandbox Code Playgroud)

Firefox也不起作用.Microsoft Edge工作得很好.这是正常的吗?

小智 7

你在"严格使用"模式吗?

ES6类通过为类提供干净,标准化的语法来解决这个问题.这种新语法适用于以严格模式编写的Chrome 42 for JavaScript.