Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/411.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.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中的类语法_Javascript_Google Chrome_Firefox_Browser_Ecmascript 6 - Fatal编程技术网

浏览器支持Javascript中的类语法

浏览器支持Javascript中的类语法,javascript,google-chrome,firefox,browser,ecmascript-6,Javascript,Google Chrome,Firefox,Browser,Ecmascript 6,下面是语法 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 Polygo

下面是语法

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:意外的令牌类(…)

已安装chrome版本
47.0.2526.80 m

已安装firefox版本
44.0a2(2015-12-12)

截至2015年12月14日,
&
扩展
关键字得到支持的浏览器版本是什么?

  • 铬42.0
  • FirefoxGecko夜间构建
  • 边缘13
  • 狩猎9


Javascript规范:



  • 您可以使用javascript-to-javascript编译器(如Babel)将ES6 javascript编译成ES5代码。它涵盖了ES6的大部分功能

  • 查看ES6功能表,以及不同浏览器对这些功能的支持程度


  • 为什么不使用支持的东西呢,
    function Polygon
    @SpencerWieczorek基于类的范例看起来更容易(接近真实世界)构建抽象我认为你需要有严格的模式才能在Chrome上工作。你知道,浏览器(跨浏览器)需要多长时间吗要支持
    语法?真正的问题是-要多久才能有足够多的人拥有支持
    语法的浏览器。我使用的是chrome版本
    47.0.2526.80M
    。这是否支持
    class
    语法?是的,但仅在严格模式下。请使用“dsoop.js”。它使用类语法,再加上更多,然后在幕后转换东西,使其与每个浏览器兼容!