作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
Google Chrome 声称从版本 42 开始支持 ES6 类,但是当我在控制台中运行下面的简单代码时,它给出了 Uncaught SyntaxError: Unexpected token class(...)
:
class Polygon {
constructor(height, width) {
this.name = 'Polygon';
this.height = height;
this.width = width;
}
Firefox 也不行。 Microsoft Edge 运行良好。这正常吗?
最佳答案
您是否处于“使用严格”模式?
ES6 classes solve this by providing JavaScript a clean, standardized syntax for classes. This new syntax is available in Chrome 42 for JavaScript written in strict mode.
关于javascript - ES6 类不适用于 Chrome 47,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34231445/
我是一名优秀的程序员,十分优秀!