0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【React初心者メモ】論理否定演算子(!)/ ダブルバン(!!)

Last updated at Posted at 2025-06-13

論理否定演算子(!)

値の「真偽(truthy / falsy)を反転する」演算子です。

!value
value が truthy → false
value が falsy → true

なぜ上記のように動くかと言うと、!は以下のように動作しています。

  1. value を boolean に強制変換する(truthy → true, falsy → false)
  2. その論理値を反転する(NOT)

ダブルバン(!!)

booleanに強制変換するために使われる演算子です。

!!value
value が truthy → true
value が falsy → false

なぜ上記のように動くかと言うと、!!は以下のように動作しています。

  1. value を boolean に強制変換する(truthy → true, falsy → false)
  2. その論理値を反転する(NOT)
  3. その論理値を更に反転する(NOT) = 元に戻る
    結果として、「Boolean としての真偽値を得る」ために使われます。
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?