17
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ES6でstatic properties

Posted at

static methodsがあるなら当然…え?

ES6を使ってみようとBabelを弄ってたんだけど、

class Foo {
    static bar: baz; // not work
    // static bar = baz; <- syntax error
}

と書いてみたら思った通りに動かず、調べてみたらstatic methodsしかサポートしてなさそうだった。

とはいえ、道具は揃っているので

static methodsとGettersがあれば、

class Foo {
    static get bar() {
        return baz;
    }
}

var qux = Foo.bar; // qux == baz

とりあえずやりたいことは出来た。

17
17
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?