javascript:syntax

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

次のリビジョン
前のリビジョン
javascript:syntax [2019/09/12 13:02] – 作成 ともやんjavascript:syntax [2019/09/12 15:44] (現在) ともやん
行 1: 行 1:
 ====== JavaScript 構文 ====== ====== JavaScript 構文 ======
  
-===== ES6 class =====+===== ES6 class static variable =====
 Chrome v72、V8 v7.2 から class の static メンバー変数をサポートしているので以下のような書き方ができる。\\ Chrome v72、V8 v7.2 から class の static メンバー変数をサポートしているので以下のような書き方ができる。\\
 ただし、この構文は Mobile Chrome では 2019/09/12 現在 v77 であるが動作しなかった。\\ ただし、この構文は Mobile Chrome では 2019/09/12 現在 v77 であるが動作しなかった。\\
行 16: 行 16:
  
 では、Mobile でも動作する static メンバー変数はどう定義するか?\\ では、Mobile でも動作する static メンバー変数はどう定義するか?\\
-それはとても簡単である。以下のように static メンバー関数内でクラスメンバー初期化するだけである。\\+それはとても簡単である。以下のように static メンバー関数内でクラスメンバーとして初期化するだけである。\\
 <code javascript> <code javascript>
 class Counter { class Counter {
   static increment() {   static increment() {
-    if (!!!this._countthis._count 0;+    this._count this._count || 0;
     return this._count++;     return this._count++;
   }   }
行 29: 行 29:
 [[https://v8.dev/features/class-fields|Public and private class fields · V8]]\\ [[https://v8.dev/features/class-fields|Public and private class fields · V8]]\\
  
 +===== 参考文献 =====
 +[[https://www.webprofessional.jp/shorthand-javascript-techniques/|あなたが知らないJavaScriptの便利すぎるショートハンド19選 - WPJ]]\\
  
  • javascript/syntax.1568260936.txt.gz
  • 最終更新: 2019/09/12 13:02
  • by ともやん