我想在中实现常量class,因为在代码中找到常量是很有意义的。
到目前为止,我一直在使用静态方法实现以下变通方法:
class MyClass {
static constant1() { return 33; }
static constant2() { return 2; }
// ...
}
我知道有可能摆弄原型,但许多人建议不要这样做。
有没有更好的方法在ES6类中实现常量?
临摹微笑
收到一只叮咚
繁星淼淼
相关分类