-
-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ES2020: Nullish coalescing Operator #1178
Comments
ES2020 から nullish という概念が増えている。 ES2019では nullish はでてこない。 |
少なくても null じゃなくて nullish なので この訳語にはできない気がする。 |
tc39/proposal-logical-assignment: A proposal to combine Logical Operators and Assignment Expressions Nullish coalescingはLogicalとついてはいないけど、実質Logicalの分類に近い気がする。 https://tc39.es/ecma262/#sec-binary-logical-operators-static-semantics-isfunctiondefinition なので、
でよさそう。 演算子(Nullish) → オブジェクト(Optional chaining) → 関数(Nullish coalescing)という順番になる。 これ系の対応
|
意外にもユースケースでは |
Nullish coalescing演算子(`??`)とOptional chaining(`?.`)に関する変更 ## 変更点 - [x] **falsy**の説明を演算子の章に移動 - falsyの対応としてnullishを演算子の章で解説するため - BigIntの `0n` も falsy に追加 #445 - [x] Optional chaining演算子の(`?.`)の解説を"オブジェクト"の章に追加 - [x] Nullish coalescing演算子(`??`)とOptional chaining(`?.`)の組み合わせを説明 - [x] Nullish coalescing演算子(`??`)の解説を"演算子"の章に追加 - [x] 一部のコードを `||` を `??` に置き換え - 例としては問題ないけど、`??` 推奨気味に変更 ## 追加しなかったこと - デフォルト値に対するNullish coalescing演算子(`??`)とOptional chaining(`?.`)の組み合わせのパターン - 他にもいろいろな書き方があるため含めないようにした - 関数呼び出しとOptional chaining演算子(`?.`) - `window.fn?.()` みたいなケース - ユースケースがイマイチ。別の解決方法でも良いと思える気がする fix #1178 fix #1179
Null合体演算子 - JavaScript | MDN
合体という訳は微妙な気がするけど、これはデフォルト引数の
||
の問題を解決する話、falsyの話と関係するので入れるのは妥当な気がする。https://jsprimer.net/basic/function-declaration/#function-default-parameters
falsyの話題自体は
if
文と関係するから残るはず。||
での判定の問題にフォーカスするのがいい気がする。デフォルト引数の解決のパターンとして並べるのが妥当かもしれない?
演算子に入るイメージはあんまりないのかも。演算子が肥大化するから、一旦演算子の章を整理して必須じゃないものは全部消すとかしてもいい。
やること
The text was updated successfully, but these errors were encountered: