本文共 393 字,大约阅读时间需要 1 分钟。
In the past, to create a public class field we would have used this syntax, instantiating the field in the constructor:
过去,要创建一个公共类字段,我们将使用以下语法,在构造函数中实例化该字段:
class Counter { constructor() { this.count = 0 }}
The new , which you can use since Chrome 72 and Node 12, allows us to use this syntax:
从Chrome 72和Node 12开始可以使用的新 ,使我们可以使用以下语法:
class Counter { count = 0}
Much simpler!
简单得多!
翻译自:
转载地址:http://ylqgb.baihongyu.com/