LoginSignup
4
5

More than 3 years have passed since last update.

javascriptの==と===の違い ❏JavaScript❏

Last updated at Posted at 2019-11-23

==は不完全一致、 ===は完全一致

違いは数値や文字列などのデータ型まで完全に一致するかどうか。

簡単に言うと、 == の厳しい版が === です。

a = 123
b = "123"

aは数値、bは文字列
これらを比較した時
trueを出すのが==
falseを出すのが===

a = 123
b = "123"

if a == b
  puts "等しい!"
end

if a === b
  puts "等しい!"
end

この場合、"等しい!"が出力されるのは==の方。


ちなみにRubyでは意味が異なり、基本的に == でOKで、
=== の使い所がなさそうなので割愛。



ではまた!

4
5
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
4
5