LoginSignup
34
8

More than 3 years have passed since last update.

Chrome 74 でクラスのプライベートフィールドが定義出来るようになりました(キモい)

Last updated at Posted at 2019-04-24

2019/04/24 日本時間で 7 時頃、 Google Chrome 74 が リリースされました

New in Chrome 74  |  Web  |  Google Developers

Chrome 72 でクラスのパブリックフィールドが定義出来るようになったことを以前紹介しましたが、今回は追加機能として、 「クラスのプライベートフィールド定義」 が可能になりました。

class A {
  _publicField = 'aa';
  #privateField = 'bb';
}
const a = new A()
console.log(a._publicField)
"aa"
console.log(a.#privateField)
VM134:1 Uncaught SyntaxError: Undefined private field #privateField: must be declared in an enclosing class

キモい。

ちなみに仕様はこちら→ tc39/proposal-class-fields: Orthogonally-informed combination of public and private fields proposals

34
8
1

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
34
8