gpt4 book ai didi

javascript - ES6 类不适用于 Chrome 47

转载 作者:数据小太阳 更新时间:2023-10-29 05:14:56 24 4
gpt4 key购买 nike

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com