5
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

updated at

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

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

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

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

a = 123
b = "123"

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

a = 123
b = "123"

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

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

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


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



ではまた!

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
5
Help us understand the problem. What are the problem?