Skip to content
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

feat(opreator): Logical assignment operatorsの追加 #1334

Closed
wants to merge 1 commit into from
Closed

feat(opreator): Logical assignment operatorsの追加 #1334

wants to merge 1 commit into from

Conversation

azu
Copy link
Collaborator

@azu azu commented Jun 27, 2021

  • 対象ページ:
  • 変更点
    • &&=||=??=を追加

他の += みたいなものとはメンタルモデルが異なるので、あんまり扱わないほうが良さそうな感じがする。

参考:

@bot-user
Copy link

✔️ Deploy Preview for js-primer ready!

🔨 Explore the source changes: d890089

🔍 Inspect the deploy log: https://app.netlify.com/sites/js-primer/deploys/60d83bdd51e4480007caf870

😎 Browse the preview: https://deploy-preview-1334--js-primer.netlify.app

<!-- doctest:meta:{ "ECMAScript": 2021 } -->
```js
// `a`がtrueのときに、`a`へ`b`を代入する
a &&= b;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これぐらい的な例を増やすの微妙な感じがするので、やっぱり対応しないほうが良さそうな気がする。

a &&= b;

a && (a = b);

という意味となる。a がtruthの場合のみassignが発生するという形になる。
つまり実際には次のようなイメージのコード。

if( a ) {
  a = b;
}

a ??= b に対応するifの書き方がない。

if( a == null ) {
  a = b
}

ではあるけど ?? がなくなっている。

a ?? (a = b);

@azu
Copy link
Collaborator Author

azu commented Jun 27, 2021

入れるならチートシートにも入れるべき。
この項目は網羅性以外の価値は低そう

本書の目的ではないことを考えると、現時点では含める必要がないと判断したので閉じる

@azu azu closed this Jun 27, 2021
@azu azu deleted the feature/logical-operator branch June 27, 2021 09:01
@azu azu mentioned this pull request Jun 27, 2021
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants