Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/425.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ES6课程不包括';我不能在铬47上工作_Javascript_Google Chrome_Ecmascript 6 - Fatal编程技术网

Javascript ES6课程不包括';我不能在铬47上工作

Javascript ES6课程不包括';我不能在铬47上工作,javascript,google-chrome,ecmascript-6,Javascript,Google Chrome,Ecmascript 6,Google Chrome声称从版本42开始就支持ES6类,但当我在控制台中从下面运行简单代码时,它给出了未捕获的SyntaxError:Unexpected token class(…): class Polygon { constructor(height, width) { this.name = 'Polygon'; this.height = height; this.width = width; } Firefox也不起作用。微软的边缘工作得很好。这

Google Chrome声称从版本42开始就支持ES6类,但当我在控制台中从下面运行简单代码时,它给出了
未捕获的SyntaxError:Unexpected token class(…)

class Polygon {
  constructor(height, width) {
    this.name = 'Polygon';
    this.height = height;
    this.width = width;
  }
Firefox也不起作用。微软的边缘工作得很好。这正常吗?

您是否处于“严格使用”模式

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


@VSG24我没有启用任何标志,
(function(){“use strict;return class Polygon{}})(
在Chrome47中对我很好。您确定您的“use strict;”声明放置正确吗?你使用的是旧版本的Chrome吗?@apsillers我宣布
“严格使用”在错误的位置。现在可以了。